Background
I'm working with a Mysql database generated from a legacy SQL dump file. Some tables have been deleted from said SQL dump file.
What I'm trying to do
I'm using SQLAlchemy and pymysql to select rows, and going by the official tutorial:
from sqlalchemy import create_engine, select, MetaData, Table
import pymysql
metadata = MetaData()
db_connection_str = f'mysql+pymysql://{db_user}:{db_password}@localhost/{db_name}'
db_connection = create_engine(db_connection_str)
test_table = Table(<table_name>, metadata, autoload_with=db_connection)
Works, but not for all tables. For one particular table (which exists in the database), it throws this error:
ProgrammingError: (pymysql.err.ProgrammingError) (1146, "Table '<missing_table_name>' doesn't exist")
[SQL: SHOW CREATE TABLE `<missing_table_name>`]
(Background on this error at: http://sqlalche.me/e/14/f405)
The existing table also contains a MUL
Key column, with a description that says it points to <missing_table_name>
. It appears that <missing_table_name>
was deleted before exporting the SQL dump file.
Is there a workaround that would allow me to select rows from the existing table?