With SQLAlchemy metadata reflect() how do you get an actual table object?

If you are not sure what tables exist initially, you can do this query to inspect the database tables.

from sqlalchemy import create_engine
from sqlalchemy.engine import reflection

# Create connection string & engine
connection_string = "sql_connection_string"
engine = create_engine(connection_string, echo=False)

# Performs database schema inspection
insp = reflection.Inspector.from_engine(engine)
print(insp.get_table_names())

Then you can select the Metadata from the table like the above answer states.

Inspector.get_table_names() returns all table names referred to within a particular schema. This does not return views. Views are instead returned using the Inspector.get_view_names() method. Docs


It is as simple as looking up the tables from the metadata object's dictionary of tables:

mytable = metadata.tables['mytable']

See "Reflecting All Tables At Once" for further info.