I'm running a flask app on google cloud, but I'm having no luck at all using pyodbc. I initially tried
def googleConnection():
conn = pyodbc.connect(
"Driver={SQL Server};"
"Server=server;"
"Database=dbname;"
"UID=username;"
"PWD=password;"
)
return conn
and I got the following error in gcloud logs:
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found (0) (SQLDriverConnect)")
It's complaining that it's missing the necessary drivers. So, I ran a query to return
pyodbc.drivers()
to see if anything was available
def googleConnection():
drivers = [item for item in pyodbc.drivers()]
conn = pyodbc.connect(
f"Driver={drivers[-1]};"
"Server=server;"
"Database=dbname;"
"UID=username;"
"PWD=password;"
)
return conn
and it just returned an empty list, confirming no drivers, but it imports pyodbc as a package, as per my requirements file.
The DB it's trying to connect to is hosted using GCP SQL and there's no issues with auth, so it really is just missing drivers. But, I can't find any documentation on adding these in. I found this that is using gcloud -beta config
but it has since been deprecated.