SQL: Some toys and little fix
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Thu, 15 Dec 2011 21:11:49 +0000 (22:11 +0100)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Thu, 15 Dec 2011 21:11:49 +0000 (22:11 +0100)
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

index 31ebfbf4a8e215f38708d877b81adddd04127e1a..a38be1cc14858d0c0102df8d8dd891e3e290ec98 100644 (file)
@@ -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()