SQL Alchemy Database Introspection through MetaData
✓ Published0🌍 Public
WWilliamQLiu
Last edited Apr 10, 2018
Created on Apr 10, 2018
This example demonstrates how to introspect a MySQL database schema and its tables using SQLAlchemy’s reflection API. It connects to a database via an engine, retrieves table names through `Inspector.get_table_names()`, and filters them by substring. It then loads a specific table into a pandas DataFrame with `read_sql_table`, and prints the table’s metadata, columns, and data types. The code also creates a `MetaData` instance, accesses a table object like `metadata.tables['stark_master']`, and calls `sa.inspect(engine)` to list all tables.
AI-generated description