question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

read_sql_table gives AttributeError when reading a database

See original GitHub issue

When I try to read from a sql database: df_database = create_engine('sqlite:///' + database_path) df = dd.read_sql_table('table', df_database, 'id_driver')

I get this error: AttributeError: 'Engine' object has no attribute '_instantiate_plugins'

If I use the pandas read_sql_query function on the same db, it works just fine.

Here’s a full trace:

AttributeError Traceback (most recent call last) ipython-input-10-2da58b7e1773 in <module>() 3 t0 = time.time() ----> 4 df = dd.read_sql_table(‘table’, df_database, ‘id_driver’) 5 t1 = time.time() 6

~/lib/python3.6/site-packages/dask/dataframe/io/sql.py in read_sql_table(table, uri, index_col, divisions, npartitions, limits, columns, bytes_per_chunk, **kwargs) 66 if index_col is None: 67 raise ValueError(“Must specify index column to partition on”) —> 68 engine = sa.create_engine(uri) 69 meta = sa.MetaData() 70 if isinstance(table, six.string_types):

~/lib/python3.6/site-packages/sqlalchemy/engine/init.py in create_engine(*args, **kwargs) 389 strategy = kwargs.pop(‘strategy’, default_strategy) 390 strategy = strategies.strategies[strategy] –> 391 return strategy.create(*args, **kwargs) 392 393

~/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py in create(self, name_or_url, **kwargs) 50 u = url.make_url(name_or_url) 51 —> 52 plugins = u._instantiate_plugins(kwargs) 53 54 u.query.pop(‘plugin’, None)

AttributeError: ‘Engine’ object has no attribute ‘_instantiate_plugins’

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
martindurantcommented, Dec 8, 2017

The second argument to read_sql_table should not be an engine, but a URI from which an engine can be made.

0reactions
garaudcommented, Nov 8, 2018

OK. I didn’t know. Thanks. I’ll try to push something soon about this “good first” issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dask read_sql_table error: 'instancemethod' object has no ...
1 Answer 1 ... The table parameter must either be an existing table (and so be a string or a sa.Table instance) or...
Read more >
dask.dataframe.read_sql_table - Dask documentation
Read SQL database table into a DataFrame. If neither divisions or npartitions is given, the memory footprint of the first few rows will...
Read more >
pandas.read_sql_table — pandas 1.5.2 documentation
Read SQL database table into a DataFrame. Given a table name and a SQLAlchemy connectable, returns a DataFrame. This function does not support...
Read more >
Introduction to Python SQL Libraries
In this step-by-step tutorial, you'll learn how to connect to different database management systems by using various Python SQL libraries.
Read more >
Python MySQL Select From Table [Complete Guide] - PYnative
1. Refer to Python MySQL database connection to connect to MySQL database from Python using MySQL Connector module 2. Next, prepare a SQL...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found