MySQL reflects from the "SHOW CREATE TABLE" output, what does that say in this case ?
On Mar 25, 2013, at 12:57 PM, Roy Smith <r...@panix.com> wrote: > Server version: 5.1.63-log MySQL Community Server (GPL) > SQLAlchemy==0.8.0 > > I've got a table which has defaults on some columns. When I discover the > table, I get the column names and types, but not the defaults. What am I > doing wrong? > > mysql> describe component; > +--------------------+--------------+------+-----+---------+-------+ > | Field | Type | Null | Key | Default | Extra | > +--------------------+--------------+------+-----+---------+-------+ > | id | int(11) | NO | PRI | NULL | | > | comp_type_id | int(11) | NO | | NULL | | > | active_status_code | varchar(1) | NO | | NULL | | > | title | varchar(255) | NO | | NULL | | > | duration | varchar(10) | NO | | NULL | | > | release_date | date | YES | | NULL | | > | seq_number | int(11) | NO | MUL | NULL | | > | amg_id | varchar(255) | NO | | | | > | isrc | varchar(12) | NO | | | | > | parental_advisory | tinyint(1) | NO | | 0 | | > | item_number | int(11) | NO | | 0 | | > | comp_code | varchar(255) | NO | | | | > | cover_art | tinyint(1) | NO | | 0 | | > | disk_number | int(11) | NO | | 0 | | > | label_id | int(11) | NO | | 0 | | > | muze_id | varchar(255) | NO | | | | > | upc | varchar(255) | NO | | | | > +--------------------+--------------+------+-----+---------+-------+ > > from sqlalchemy.schema import MetaData > credentials = {...} > url = "mysql://{user}:{password}@{host}/{database}".format(**credentials) > metadata = MetaData(url) > metadata.reflect() > for column in metadata.tables['component'].columns: > print "%s: %s %s" % (column.name, column.type, column.default) > > prints: > > id: INTEGER(11) None > comp_type_id: INTEGER(11) None > active_status_code: VARCHAR(1) None > title: VARCHAR(255) None > duration: VARCHAR(10) None > release_date: DATE None > seq_number: INTEGER(11) None > amg_id: VARCHAR(255) None > isrc: VARCHAR(12) None > parental_advisory: TINYINT(1) None > item_number: INTEGER(11) None > comp_code: VARCHAR(255) None > cover_art: TINYINT(1) None > disk_number: INTEGER(11) None > label_id: INTEGER(11) None > muze_id: VARCHAR(255) None > upc: VARCHAR(255) None > > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+unsubscr...@googlegroups.com. > To post to this group, send email to sqlalchemy@googlegroups.com. > Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.