Commits

Guido Draheim  committed 8dd0826

update to sqlalchemy 0.7

  • Participants
  • Parent commits 019bae0

Comments (0)

Files changed (2)

File src/dvbcronrecording/db/schema.py

 
-import dvbcronrecording.db.db4 as _db 
+import dvbcronrecording.db.db5 as _db
 
 metadata = _db.metadata
 tables = metadata.sorted_tables # support old aff() detection
 RecordingChannelsConf = _db.RecordingChannelsConf
 RecordingList = _db.RecordingList
 RecordingChanges = _db.RecordingChanges
+ProgramguideChannels = _db.ProgramguideChannels
 
 pass

File src/dvbcronrecording/db/schemachange.py

+# NOTE: I just came across this, a migration tool from the author of sqlalchemy
+# https://bitbucket.org/zzzeek/alembic
+
+
 import schemadiff
-import tsab
+import tsab2 as tsab
+import sys
+
+import sqlalchemy
 
 def alter_sql_AtoB(metadataA, metadataB, env, excludeTables = None):
     """ given a SchemaDiff instance, generate the corresponding
     changer = Changer(diff, env)
     for change in changer.migrateBtoA():
             yield change
-7            
-class DummyStatement:
-    def supports_execution(self):
-        return False
+
+import sqlalchemy.sql.expression
+class SchemaChangeElement(sqlalchemy.sql.expression.ClauseElement):
+    __visit_name__ = "schema_change"
     
 class Changer:
     def __init__(self, schemadiff, env):
         self._engine = None
         self._session = None
     def engine(self):
+        print >> sys.stderr, "ENGINE"
         if self._engine is None:
             self._engine = tsab.engine(self.env)
         return self._engine
                 print "unkonwn dialect", self.dialect()
         return self._ddl_dialect
     def ddl_compiler(self):
+        """ we do all DDL compilation ourselves. But we take advantage of
+            the ddl.get_column_specification(coldef) sql conversions. """
         if self._ddl_compiler is None:
-            statement = DummyStatement()
+            statement = SchemaChangeElement()
             if self.dialect() in [ "sqlite" ]:
                 # import sqlalchemy.dialects.sqlite.base
                 dialect = self.ddl_dialect()
                 import sqlalchemy.dialects.sqlite.base
-                q = sqlalchemy.dialects.sqlite.base.SQLiteDDLCompiler(dialect, statement)
+                class SQLiteDDL(sqlalchemy.dialects.sqlite.base.SQLiteDDLCompiler):
+                    def visit_schema_change(self, s):
+                        """ SQLAlchemy 0.7 compiles immediately on __init__ """
+                        pass
+                q = SQLiteDDL(dialect, statement)
                 # q = dialect.ddl_compiler(dialect, statement)
                 self._ddl_compiler = q
             else: