conta's diary

思ったこと、やったことを書いてます。 twitter: @conta_

2012-07-04から1日間の記事一覧

SQLAlchemyで動的にテーブルを作る2

うーん、いいのかなぁー。もっとリファレンス読まないと。。。 Create engine = sqlalchemy.create_engine(engine_str, echo=True) def create_test_table(table_name): test_info = TestInfo.__table__ test_info.name = table_name test_info.create(engin…

SQLAlchemyで動的にテーブルを作る

Base.create_all(engine)とすると定義されてるテーブルが全部作られちゃう。 定義してあるけど後でテーブルを動的に作りたい!と思ってやってみた。 一応動いたけど正しいのかどうかは不明。。。リファレンスに、 Base = declarative_base() class TestInfo(…