I'm trying to connect c-TreeSQL using Python. I know I have the correct driver because I can connect using George Poulose's Query Tool
I have tried these variations and each one has crashed;
import pyodbc
## Instructions from http://doc.4d.com/4Dv17/4D/17/Using-a-connection-string.200-3786162.en.html
# conn = pyodbc.connect('Driver={c-treeACE ODBC Driver};Host=<Host from driver config>;UID=<User name>;PWD=<Password>;DATABASE=liveSQL;')
# Connection string from Query Tool
# conn = pyodbc.connect('Driver={c-treeACE ODBC Driver};ODBC;DSN=DOTLIVEREP;Host=<Host from driver config>;UID=<User name>;PWD=<Password>;DATABASE=liveSQL;SERVICE=6597 ;CHARSET NAME=;MAXROWS=;OPTIONS=;;PRSRVCUR=OFF;;FILEDSN=;SAVEFILE=;FETCH_SIZE=;QUERY_TIMEOUT=;SCROLLCUR=OFF;')
# Connection string from Query Tool. Added driver parameter
conn = pyodbc.connect('ODBC;DSN=DOTLIVEREP;Host=<Host from driver config>;UID=<User name>;PWD=<Password>;DATABASE=liveSQL;SERVICE=6597 ;CHARSET NAME=;MAXROWS=;OPTIONS=;;PRSRVCUR=OFF;;FILEDSN=;SAVEFILE=;FETCH_SIZE=;QUERY_TIMEOUT=;SCROLLCUR=OFF;')
print('Success')
Each one of these connection strings causes a crash in PyCharm, IDLE, and the console.
I'm not sure what would be causing this
you should change the field in the connection string where is for the specific value of your application.
For example here, instead of < Host from driver config >. Lets say your host is MYHOST. You should put MYHOST. Same thing for < User name >, you should put your username, like jacob, and so on. Normally these field with brackets are the on you have put a value:
# Connection string from Query Tool. Added driver parameter
conn = pyodbc.connect('ODBC;DSN=DOTLIVEREP;Host=MYHOST;UID=jacob;PWD=<Password>;DATABASE=liveSQL;SERVICE=6597 ;CHARSET NAME=;MAXROWS=;OPTIONS=;;PRSRVCUR=OFF;;FILEDSN=;SAVEFILE=;FETCH_SIZE=;QUERY_TIMEOUT=;SCROLLCUR=OFF;')
Even tho I haven't had the same issue like you had, here's my fix for the error while using pyodbc and MS SQL Server:
I tried to connect to multiple databases on the same server right at the beginning of my code. When I tried connecting to a second database on the same server, my code threw this error.
What I did to fix it was to close my first connection to the server before, do the work that needed to be done, and close the connection afterwords. Then I connected to my second database and everything worked fine.
User contributions licensed under CC BY-SA 3.0