import pyodbc
con=pyodbc.connect('Driver={SQL Server};Server=New;Database=Countrydatabase;Trusted_connection=yes')
cur=con.cursor()
cur.execute("TRUNCATE Countrydatabase..region")
con.close()
I am trying to truncate a table using the pyodbc module. But it keeps throwing an error.
Traceback (most recent call last): File "C:/Users/sean/Desktop/script.py", line 6, in cur.execute("TRUNCATE Countrydatabase..region") pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'Countrydatabase'. (102) (SQLExecDirectW)")
Same code works fine when I use "SELECT" statement.