Created
May 6, 2015 16:17
-
-
Save inklesspen/59f44616dcaa2e89bcde to your computer and use it in GitHub Desktop.
sqlacodegen wish list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sqlacodegen with --noclasses produces tables that look like this: | |
t_match_matchrelationship = Table( | |
'match_matchrelationship', metadata, | |
Column('id', BigInteger, primary_key=True, server_default=text("nextval('match_matchrelationship_id_seq'::regclass)")), | |
Column('created_on', DateTime(True), nullable=False, index=True), | |
Column('opportunity_id', ForeignKey(u'opportunities_opportunity.id'), nullable=False, index=True), | |
Column('transaction_profile_id', ForeignKey(u'transaction_profile.transaction_data_id'), index=True), | |
Column('score', BigInteger, nullable=False), | |
Column('sent_date', DateTime(True), index=True), | |
Column('pursued_on', DateTime(True)), | |
Column('replied_on', DateTime(True)), | |
Index('idx_17303_match_matchrelationship_opportunity_id_4a214d2e', 'opportunity_id', 'score'), | |
) | |
# but sometimes i need tables that look like this, using sqlalchemy.sql.expression.table and sqlalchemy.sql.expression.column: | |
# http://docs.sqlalchemy.org/en/rel_0_9/core/sqlelement.html#sqlalchemy.sql.expression.column | |
t_match_matchrelationship = sa.sql.table( | |
'match_matchrelationship', | |
sa.sql.column('id', sa.BigInteger), # all keyword arguments omitted | |
sa.sql.column('created_on', sa.DateTime(True)), # types prefixed by sa. so i can do "import sqlalchemy as sa" and get all i need | |
sa.sql.column('opportunity_id', sa.BigInteger), # needs the type instead of foreignkey | |
sa.sql.column('transaction_profile_id', sa.BigInteger), | |
sa.sql.column('score', sa.BigInteger), | |
sa.sql.column('sent_date', sa.DateTime(True)), | |
sa.sql.column('pursued_on', sa.DateTime(True)), | |
sa.sql.column('replied_on', sa.DateTime(True)), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment