tsql

SQLAlchemy 1.4 tutorial code "'Connection' object has no attribute 'commit'" error or does not commit changes

SQLAlchemy 1.4 tutorial code "'Connection' object has no attribute 'commit'" error or does not commit changes Question: Here is some custom code I wrote that I think might be problematic for this particular use case. class SQLServerConnection: def __init__(self, database): … self.connection_string = "DRIVER=" + str(self.driver) + ";" + "SERVER=" + str(self.server) + ";" + …

Total answers: 3

Retrieve data from sql server database using Python

Retrieve data from sql server database using Python Question: I am trying to execute the following script. but I don’t get neither the desired results nor a error message ,and I can’t figure out where I’m doing wrong. import pyodbc cnxn = pyodbc.connect(“Driver={SQL Server Native Client 11.0};” “Server=mySRVERNAME;” “Database=MYDB;” “uid=sa;pwd=MYPWD;” “Trusted_Connection=yes;”) cursor = cnxn.cursor() cursor.execute(‘select …

Total answers: 4

What's causing 'unable to connect to data source' for pyodbc?

What's causing 'unable to connect to data source' for pyodbc? Question: I’m trying to connect to an MSSQL database from python on Linux (SLES). I have installed pyodbc and Free TDS. From the command line: tsql -H server -p 1433 -U username -P password Connects to the server without a problem, however, from Python: import …

Total answers: 13