I am trying to get information from a SQL database using python
I managed to connect and get data when the SQL statement was simple, for example
#cursor.execute("SELECT * FROM Client WHERE UsesTimesheet = 1 ORDER BY ClientName")
However, when I move on to a more complex expression, I get the error message below
Traceback (most recent call last): File "F:\Python\Test - AutoCad.py", line 30, in <module> where jobnum = 1205992") File "C:\Python26\ArcGIS10.0\lib\site-packages\pymssql.py", line 196, in execute raise OperationalError, e[0] OperationalError: SQL Server message 102, severity 15, state 1, line 1: Incorrect syntax near 'jobnum'.
This statement works when I use the Microsoft SQL 2008 client, but not in python.
What am I doing wrong? For complex statements, should I use SQLAlchemy?
http://www.sqlalchemy.org/
Current code below
import pymssql import _mssql import sys
Tristan forward
source share