I am using Ubuntu. I want to access Microsoft sql database using pyodbc in django. I installed all requirements. To do that, I wrote this
cursor.execute('SELECT Id FROM %s' %table_name)
I am getting error which is
[HY004] [FreeTDS][SQL Server]Invalid data type (0) (SQLBindParameter)')
But, when I try this
cursor.execute('SELECT * FROM mytable')
It works fine. Why do I see that error, Is there a way to solve that issue ?
SQL Server doesn't support variables for table names. Try building the whole statement as a string and then executing it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With