1

when trying to connecnt to my local sql server i keep on getting the following error:

pyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')

this is my code:

import pyodbc


conn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=127.0.0.1;port=32782;DATABASE=db;UID=db;PWD=db;Trusted_Connection=yes')

cursor = conn.cursor()
cursor.execute('SELECT * FROM db.tt_content LIMIT 3')

for row in cursor:
    print(row)

Note: this sql server inside a ddev container

Note2: i tried SERVER=127.0.0.1,32782 and got the same result

2
  • I don't know what a "ddev container" is, but it may well have its own IP address. If so, then you'd have to use that one instead of localhost (127.0.0.1). Commented Dec 27, 2019 at 16:12
  • i don't think so as i can connect to the DB with another tool on the same IP and port Commented Jan 10, 2020 at 14:22

1 Answer 1

1

So it turnsout that my database is a mariaDB so i used mysql.connector instead and it connected

Not the answer you're looking for? Browse other questions tagged or ask your own question.