Note that there are some explanatory texts on larger screens.

plurals
  1. POSqlAlchemy Migrate Declarative
    primarykey
    data
    text
    <p>I've modified the tutorial on the SqlAlchemy-Migrate <a href="http://packages.python.org/sqlalchemy-migrate/versioning.html#edit-the-change-script" rel="noreferrer">tutorial</a> to declarative syntax for my Pylons Pyramid project. I can successfully upgrade and downgrade, but I'm concerned about the <code>Base.metadata.drop_all</code>(migrate_engine) command below. Here is my migration file:</p> <pre><code>from sqlalchemy import Column from sqlalchemy.types import Integer, String, DateTime from sqlalchemy.sql import func from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import scoped_session, sessionmaker from zope.sqlalchemy import ZopeTransactionExtension DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) Base = declarative_base() class User(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True) email = Column(String(75), unique=True) fullname = Column(String(60)) password = Column(String(51)) last_login = Column(DateTime) date_joined = Column(DateTime, default=func.now()) def upgrade(migrate_engine): # Upgrade operations go here. Don't create your own engine; bind migrate_engine # to your metadata Base.metadata.bind = migrate_engine Base.metadata.create_all(migrate_engine) # IS THIS DANGEROUS? def downgrade(migrate_engine): # Operations to reverse the above upgrade go here. Base.metadata.bind = migrate_engine Base.metadata.drop_all(migrate_engine) # IS THIS DANGEROUS? </code></pre> <p>[edit] My question was how to individually create tables. I didn't know this was my question until asking the wrong question enough, to get to the correct question.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload