The (I think) simple question - how can I use SQL Alchemy automap extension to list the columns of a table within a schema - importantly - of an existing mysql database??
This is what I have been attempting (trying to follow docs here: Automap):
metadata = MetaData()
metadata.reflect(engine)
Base = automap_base(metadata=metadata)
Base.prepare()
From this point, I can 'see' all the tables (e.g. Base.classes.table1
, Base.classes.table2
etc), and can 'see' the columns in a particular table as attributes of each table (e.g. Base.classes.table1.column1
, Base.classes.column2
).
The question is basically is there a simple way to list the columns in the tables? (or indeed the tables in the schema?).. Something analagous to SHOW COLUMNS IN 'table1'
... Maybe I am missing somethings obvious / basic here.
A perhaps related comment - I have been both a mysql admin/user and a python user for several years now, and I am only just dipping my toes into the ORM world. Maybe I am just slow, but I am finding the docs for SQL Alchemy to be pretty impenetrable - there is seems to be mountains and mountains of documentation (and whole new vocabularly to use)... or maybe I am just thinking about ORM in completely the wrong way - so any basic guides etc - that aren't from SQL Alchemy - would be appreciated. Perhaps something along the lines of "SQL Alchemy for SQL users" - if such a thing exists..