0

When using pandas, I can connect to

import sqlalchemy as db

db.create_engine('sqlite:///C:\db\PositionTrackDB.db')

Now, I am trying to replace pandas with modin.pandas and work with databases. But no matter what I try, I always get the error of an unsupported database:

import modin.pandas as pd 
from modin.db_conn import ModinDatabaseConnection

conn = ModinDatabaseConnection('sqlite:///test.db')

Error:

modin.db_conn.UnsupportedDatabaseException: Unsupported database library sqlite:///test.db

The official documentation is not very helpful for this error: https://modin.readthedocs.io/en/0.12.0/using_modin.html

Any help greatly appreciated!


EDIT:

This fixed this issue but since the connection is properly established, it complains that it cant find the table:

import modin.pandas as pd 
from modin.db_conn import ModinDatabaseConnection

conn = ModinDatabaseConnection('sqlalchemy', 'sqlite:///test.db')

# Can use get_connection to get underlying sqlalchemy engine
conn.get_connection()

Error:

[SQL: SELECT COUNT(*) FROM (['TEST']) AS _] (Background on this error at: sqlalche.me/e/14/e3q8)

I run inspector.get_table_names() and it clearly tells me

['TEST']

..not sure what the proper syntax might be?

Dalalama231123
  • 101
  • 1
  • 1
  • 7

1 Answers1

2

Thanks for asking this question!

Firstly, you can go ahead and try to use pd.read_sql as you would in pandas and things should still work as expect. Secondly, I believe you are using ModinDatabaseConnection incorrectly (some of this is our fault for making the error messages a little vague). The constructor actually expect you to pass in the underlying SQL library to use and then takes in arguments to pass in to create that engine. Could you try something like this:

import modin.pandas as pd 
from modin.db_conn import ModinDatabaseConnection

conn = ModinDatabaseConnection('sqlalchemy', 'sqlite:///test.db')

# Can use get_connection to get underlying sqlalchemy engine
conn.get_connection()

This should be able to create a working conn object that you can pass into read_sql. The original problem that you were facing was that you were passing the entire db connection as the lib argument.

  • Thanks. this fixed this error but now I get another one. It keeps saying no such table: 'TEST', but when I run inspector.get_table_names() it clearly tells me ['TEST']. Error: [SQL: SELECT COUNT(*) FROM (['TEST']) AS _] (Background on this error at: https://sqlalche.me/e/14/e3q8) – Dalalama231123 Aug 18 '22 at 21:08
  • Could you post a stack trace or open a Github issue so we can see what's going on? I need a bit more context :) – Karthik Velayutham Aug 19 '22 at 13:45
  • Thanks for helping! Not sure what a stack trace is. But you could reproduce the issues quite easily, no? It says that is can't find the table 'TABLE' - I am sure there is maybe just a syntax issue but the documentation doesn't say much about it :( - updated the post! – Dalalama231123 Aug 19 '22 at 23:06