Hi all,
If I work on windows PC I have no problem to import and use pyodbc, BUT when I tried it on my MacBook with M2 chip it doesnt work … so … how to import pyodbc (to connect to sql server database) on my macbook with m2 chip?
Thanks a lot
Hi all,
If I work on windows PC I have no problem to import and use pyodbc, BUT when I tried it on my MacBook with M2 chip it doesnt work … so … how to import pyodbc (to connect to sql server database) on my macbook with m2 chip?
Thanks a lot
You need to provide some more detail. What error do you get when importing it? Are you sure it’s installed? A full traceback would also be helpful.
Hi,
pyp3 install pyodbc
import pyodbc
print("Hello worlds")
ERROR:
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pyodbc.cpython-311-darwin.so, 0x0002): symbol not found in flat namespace '_SQLAllocHandle'
Ahhh… Try following the clues here:
Looks like you are missing some underlying libraries.
Thanks, seems that helped … no I am trying to connect to sql server database but I shows me an error:
pyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 18 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')
my code:
drivers = pyodbc.drivers()
for d in drivers:
print(d)
conn = pyodbc.connect('DRIVER={ODBC Driver 18 for SQL Server}; \
Server=SERVER-NAME; \
Database=DTB-NME; \
User ID=USERNAME; \
Password=PASS')
cursor = conn.cursor()
cursor.execute('SELECT name FROM cars')
for i in cursor:
print(i)
what’s wrong? It
Can’t help with that. I haven’t really touch SQL since retiring a few years ago.