Created
September 24, 2012 14:10
-
-
Save bbinet/3776134 to your computer and use it in GitHub Desktop.
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
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy import Column, Index | |
from sqlalchemy.orm import scoped_session, sessionmaker | |
from sqlalchemy.types import Integer, String | |
Base = declarative_base() | |
Base.metadata.bind = "postgres://user:pass@localhost/sqla_test" | |
meta = Base.metadata | |
session = scoped_session(sessionmaker(bind=meta.bind))() | |
class Test(Base): | |
__tablename__ = 'test' | |
__table_args__ = { | |
'schema': 'app' | |
} | |
id = Column(Integer, primary_key=True) | |
name = Column(String(20)) | |
meta.drop_all() | |
meta.create_all() | |
i = Index('my_idx', Test.__table__.c.name) | |
i.create() | |
i.drop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment