I am using SQLAlchemy 0.4.8 with Postgres in order to manage my datastore. Until now, it's been fairly easy to automatically deploy my database: I was using metadata.create_all(bind=engine)
and everything worked just fine. But now I am trying to create a sequence that it's not being used by any table, so create_all()
doesn't create it, even though it's define correctly:
Sequence('my_seq', metadata=myMetadata)
.
Any thoughts on how I could make this work ?
P.S. And it's not possible at the moment to upgrade to a newer version of SQLAlchemy.
Creating and Inserting Data into Tables By passing the database which is not present, to the engine then sqlalchemy automatically creates a new database.
Creating and Dropping Database Tables create_all() creates foreign key constraints between tables usually inline with the table definition itself, and for this reason it also generates the tables in order of their dependency.
Sqlalchemy create_all method is used to create a new table into the database. This method will first check whether the table exists in the database or not if suppose it has found an existing table it will not create any table.
Could you call the create
it by using its own Sequence.create method:
my_seq = Sequence('my_seq', metadata=myMetadata)
# ...
metadata.create_all(bind=engine)
# @note: create unused objects explicitly
my_seq.create(bind=engine)
# ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With