Trying to setup a simple ODBC project. To make sure I name the correct driver in the connection, I wanted to have pyodbc report the current drivers.
Is pyodbc.drivers() supposed to report this information, or is there more to do after the call to see the list of drivers?
Windows 10 VSCode python 3.7.2 64-bit no virtual environment python freeze reports pyodbc==4.0.30 (& also 4.0.27)
Windows ODBC Data Source Administrator both (32 & 64 bit) show many drivers. MS Excel is working with PostgreSQL.
import pyodbc
Print("List of ODBC drivers:")
pyodbc.drivers()
print("End of List")
Just gives terminal output:
List of ODBC drivers:
End of List
Initially, import pyodbc was causing an exception. Un-installed pyodbc, rebooted, re-installed, that seemed to sort the exceptions out, but not the results I was looking for.
Tried going back to pyodbc 4.0.27 no change
Edited, because I sorted it out:
The answer is that, yes there is more to do. pyodbc.drivers() returns a list To get the driver names, I needed to do:
import pyodbc
print("List of ODBC Drivers:")
dlist = pyodbc.drivers()
for drvr in dlist:
print(drvr)
print("End of List")
And I now get:
List of ODBC Drivers:
SQL Server
QB SQL Anywhere
Transoft 64 bit ODBC Driver
PostgreSQL ODBC Driver(ANSI)
PostgreSQL ODBC Driver(UNICODE)
End of List
Which is what I needed.
The list only contains the 64 bit drivers, because I'm using 64 bit python.