0

I have the following code:

import psycopg2 conn_string = "dbname=ASCTP, user=TNET\user, password=password, host=ADHMSI-AR-5P, port=1433, sslmode=require" conn = psycopg2.connect(conn_string)

I'm getting this error: OperationalError: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.

That's all that I'm running in the cell. I'm wondering if there is something more that I need to add in order to keep this connection. Do I need an additional argument? I have my actual SQL SELECT statement in a following cell.

1 Answer 1

0

I abandoned psycopg2 and used this code.

conn_str = (
    r'Driver={SQL Server};'
    r'Server=.\SQLEXPRESS;'
    r'Database=myDB;'
    r'Trusted_Connection=yes;'
    )
cnxn = pyodbc.connect(conn_str)

I found this code on another Stack Overflow board. I didn't figure out what the problem was, but at least I successfully connected.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.