Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a read_sql using pandas and it works fine. However, when I tried to re-create the same dataframe under Dask using the same logic. It gives me NoSuchTableError. I know for sure the table exists in my SQL database.

Has anyone came across the same/similar issue? Any thought is much appreciated! Thanks in advance.

What I have tried:

pandas #works:
Python
import urllib
import sqlalchemy as sa
import pandas as pd

sql = "SELECT * FROM my_table"
params = urllib.parse.quote_plus("DRIVER={SQL Server Native Client 11.0};\
                             SERVER=my_server;\
                             DATABASE=db_name;\
                             Trusted_Connection=yes;")
engine = sa.create_engine('mssql+pyodbc:///?odbc_connect=%s' % params)
df = pd.read_sql(sql, engine)
print(df.head())

Dask #NoSuchTableError:
Python
import urllib
import sqlalchemy as sa
import dask.dataframe as dd
from sqlalchemy.engine.url import make_url

params = urllib.parse.quote_plus("DRIVER={SQL Server Native Client 11.0};\
                             SERVER=my_server;\
                             DATABASE=db_name;\
                             Trusted_Connection=yes;")
conn_str = 'mssql+pyodbc:///?odbc_connect={}'.format(params)
url = make_url(conn_str)
df = dd.read_sql_table('my_table', url, index_col='ID')
print(df.head())
Posted
Updated 30-Sep-20 6:40am
v2
Comments
Richard Deeming 30-Sep-20 13:00pm    
Either you're not connecting to the database you think you're connecting to, or the user you're connecting as doesn't have permission to access the specified table.
Xwnola 30-Sep-20 13:12pm    
Thank you for the reply. The interesting thing is that I have no issue connecting to the same table in the same database using pandas, but just cannot replicate the same with Dask. The URLs I used between these two are the same.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900