Dask如何在Python中读取SQL Server
我必须使用dask数据帧,因为我的数据是巨大的1.5亿行和50000列 我试着用Dask如何在Python中读取SQL Server,python,odbc,dask,pyodbc,Python,Odbc,Dask,Pyodbc,我必须使用dask数据帧,因为我的数据是巨大的1.5亿行和50000列 我试着用 conn = pyodbc.connect('Driver={SQL Server};' 'Server=DELL;' 'Database=DB;' 'Trusted_Connection=yes;') df_features = dd.read_sql_table(table="Fe
conn = pyodbc.connect('Driver={SQL Server};'
'Server=DELL;'
'Database=DB;'
'Trusted_Connection=yes;')
df_features = dd.read_sql_table(table="Features" , con=conn , index_col="ID")
我犯了这个错误
TypeError: read_sql_table() missing 1 required positional argument: 'uri'
OperationalError: (pyodbc.OperationalError) ('08001', '[08001] [Microsoft][ODBC SQL Server Driver]Neither DSN nor SERVER keyword supplied (0) (SQLDriverConnect)')
(Background on this error at: http://sqlalche.me/e/e3q8)
所以我试过这个
df_features = dd.read_sql_table(table="Features" , uri="mssql+pyodbc:///?odbc_connect=Driver={SQL Server}; Server=DELL; Database=DB; Trusted_Connection=yes;", index_col="ID")
我犯了这个错误
TypeError: read_sql_table() missing 1 required positional argument: 'uri'
OperationalError: (pyodbc.OperationalError) ('08001', '[08001] [Microsoft][ODBC SQL Server Driver]Neither DSN nor SERVER keyword supplied (0) (SQLDriverConnect)')
(Background on this error at: http://sqlalche.me/e/e3q8)
如何在dask数据帧中连接到SQL Server?@Giorgos Myrianthous的思路是正确的:您需要一个URI,而不是一些连接对象。此URI的格式必须是SQLalchemy能够理解的,因此请阅读他们的文档,了解如何为ODBC设置格式 文件:
原因是,Dask需要能够序列化和传递任务,但不能序列化连接对象。但是,如果您仅使用线程,则可以传递SQLalchemy引擎对象(这在master中) Windows ODBC驱动程序管理器在关键字和
=
下面应该可以做到这一点:
df_features = dd.read_sql_table(
table="Features",
uri="mssql+pyodbc:///?odbc_connect=DRIVER={SQL Server};SERVER=my.db.server;DATABASE=DB;Trusted_Connection=yes;",
index_col="ID"
)
你能连接到数据库吗
isql-v-k”“
我可以使用Pandas数据帧使用相同的连接字符串进行连接,但dask不工作/etc/ssl/openssl.cnf是什么?你能试试吗uri=“mssql+pyodbc://?odbc\u connect=Driver={SQL Server};Server=DELL;DATABASE=DB;Trusted\u Connection=yes;”
这与我尝试的相同,并给出了错误