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.

SoSincere3
  • 117
  • 1
  • 10

1 Answers1

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.

SoSincere3
  • 117
  • 1
  • 10