I've the following piece of code in Python, to connect to SQL Server but it always fails, even though the same from sqlcmd works.
Any ideas?
import pypyodbc
conn = pypyodbc.connect(DRIVER='{SQL Server}',Trusted_Connection='yes',server='sqldev\dwmaster',DATABASE='risk')
cur = conn.cursor()
The error I'm getting is:
pypyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server Driver ][SQL Server]Unclosed quotation mark after the character string ' '.")
Fixed the error, doing the following.
conn = pypyodbc.connect("DRIVER={SQL Server};server='sqldev\\master',Database='risk',TrustedConnection=yes")
cur = conn.cursor()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.