read.sql_query works, read sql_table doesn't

NIFIK

Trying to import a table from a SQLite into Pandas DF:

import pandas as pd
import sqlite3

cnxn = sqlite3.Connection("my_db.db")
c = cnxn.cursor()

Using this command works: pd.read_sql_query('select * from table1', con=cnxn). This doesn't : df = pd.read_sql_table('table1', con=cnxn).

Response :

ValueError: Table table1 not found

What could be the issue?

NIFIK

Using SQLite in Python the pd.read_sql_table() is not possible. Info found in Pandas doc.

Hence it's considered to be a DB-API when running the commands thru Python.

pd.read_sql_table() Documentation

Given a table name and a SQLAlchemy connectable, returns a DataFrame. This function does not support DBAPI connections.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related