我无法确定需要传递给create engine语句的正确ODBC字符串。
import pyodbc
import pandas as pd
cnxn=pyodbc.connect('DRIVER=/opt/teradata/client/ODBC_64/lib/tdata.so;DBCName=Server;UID=UN;PWD=PW;Database=myDB')
query = "select top 10 * from TABLE"
df = pd.read_sql(query,cnxn)
import urllib
import sqlalchemy
params = urllib.parse.quote_plus('DRIVER=/opt/teradata/client/ODBC_64/lib/tdata.so;DBCName=Server;UID=UN;PWD=PW;Database=myDB')
engine = sqlalchemy.create_engine("mssql+pyodbc:///?odbc_connect=%s" % params)
query = "select top 10 * from TABLE"
df = pd.read_sql_query(query, engine)
我可以使pyodbc连接正常工作,但不能使sqlalchemy连接正常工作。任何帮助,将不胜感激。
我收到此错误:
InterfaceError: (pyodbc.InterfaceError) ('IM001', '[IM001] [unixODBC][Driver Manager]Driver does not support this function (0) (SQLGetInfo)')