Process finished with exit code -1073741819 (0xC0000005) in PyCharm, RESTART: Shell in IDLE, and closes console

535 views Asked by At

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

3

There are 3 answers

2
Michael Leung On

To anyone who has been smashing their head against the wall for hours on this one, just use the ODBC library instead of the PyODBC library: once you use ODBC.odbc() to connect with the exact same connection string, everything works.

I have no idea what it is with the c-tree driver VS PyODBC library (my client used Attache and it was using a variation of the c-tree driver to connect, the driver is 32 bit but not sure if that's part of the issue since I also use 32 bit Python), it just makes the Python.exe crash as soon as it connects in my case.

0
M. Schhmidt On

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.

0
Guilherme Kich On

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;')