I'm reading a connection string for an SQL Server database from the user, represented by randomstring here. When I print randomstring to the console it looks perfectly formed, and I've been over it a dozen times to check. However, the connection fails with
pypyodbc.Error: ('IM002', '[IM002] [Microsoft]
If I explicitly pass the exact same string to the cursor, the connection works fine. Do I need to do anything specific with the string variable to be able to use it ?
randomstring = ShowConnString(self.cframe).connstringtext
print(randomstring)
self.conn = pypyodbc.connect(randomstring)
#self.conn = pypyodbc.connect(driver='{SQL Server}', server='(local)', database='Audit', uid='sa', pwd='password')
Edit: print (randomstring) outputs:
pypyodbc.connect(driver='{SQL Server}', server='(local)', database='Audit', uid='sa', pwd='password')