From e365f980ac21a403a50f61ae687d7dc04760f8bb Mon Sep 17 00:00:00 2001 From: Elrond Date: Thu, 15 Dec 2011 22:11:49 +0100 Subject: [PATCH] SQL: Some toys and little fix Run bin/python mediagoblin/db/sql/models.py and watch the create tables on a memory sqlite db. Also unicode strings need unicode defauls. Warning by sqlalchemy. --- mediagoblin/db/sql/models.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mediagoblin/db/sql/models.py b/mediagoblin/db/sql/models.py index 31ebfbf4..a38be1cc 100644 --- a/mediagoblin/db/sql/models.py +++ b/mediagoblin/db/sql/models.py @@ -18,7 +18,7 @@ class User(Base): created = Column(DateTime, nullable=False, default=datetime.datetime.now) pw_hash = Column(Unicode, nullable=False) email_verified = Column(Boolean) - status = Column(Unicode, default="needs_email_verification", nullable=False) + status = Column(Unicode, default=u"needs_email_verification", nullable=False) verification_key = Column(Unicode) is_admin = Column(Boolean, default=False, nullable=False) url = Column(Unicode) @@ -93,3 +93,14 @@ class MediaComment(Base): created = Column(DateTime, nullable=False, default=datetime.datetime.now) content = Column(UnicodeText, nullable=False) content_html = Column(UnicodeText) + + +def show_table_init(): + from sqlalchemy import create_engine + engine = create_engine('sqlite:///:memory:', echo=True) + + Base.metadata.create_all(engine) + + +if __name__ == '__main__': + show_table_init() -- 2.25.1