Commits

Fayaz Khan committed 9d922f9

turn it into a single file

  • Participants
  • Parent commits 86cd0cd

Comments (0)

Files changed (2)

                 new_column.primary_key = self.primary_key_flag
             table.append_column(new_column)
         super(ImplicitForeignKeyConstraint, self)._set_parent(table)
+
+
+def example_main():
+    from sqlalchemy.schema import Column, Table
+    from sqlalchemy.types import Integer
+    from sqlalchemy.engine import create_engine
+    from sqlalchemy.ext.declarative import declarative_base
+
+    from implicit import ImplicitForeignKeyConstraint
+
+    Base = declarative_base(bind=create_engine('sqlite://', echo=True))
+
+    class A(Base):
+
+        __tablename__ = 'a'
+        id = Column(Integer, primary_key=True)
+
+
+    class B(Base):
+
+        __tablename__ = 'b'
+        #id = Column(Integer, primary_key=True, autoincrement=False)
+        __table_args__ = (ImplicitForeignKeyConstraint(['id'], ['a.id']),)
+
+
+    t = (Table(
+            'c', Base.metadata,
+            #Column('id', Integer, primary_key=True, autoincrement=False),
+            ImplicitForeignKeyConstraint(['id'], ['a.id'], primary_key=False)))
+
+    Base.metadata.create_all()
+
+if __name__ == "__main__":
+    example_main()

File test.py

-from sqlalchemy.schema import Column, Table
-from sqlalchemy.types import Integer
-from sqlalchemy.engine import create_engine
-from sqlalchemy.ext.declarative import declarative_base
-
-from implicit import ImplicitForeignKeyConstraint
-
-Base = declarative_base(bind=create_engine('sqlite://', echo=True))
-
-class A(Base):
-
-    __tablename__ = 'a'
-    id = Column(Integer, primary_key=True)
-
-
-class B(Base):
-
-    __tablename__ = 'b'
-    #id = Column(Integer, primary_key=True, autoincrement=False)
-    __table_args__ = (ImplicitForeignKeyConstraint(['id'], ['a.id']),)
-
-
-t = (Table(
-        'c', Base.metadata,
-        #Column('id', Integer, primary_key=True, autoincrement=False),
-        ImplicitForeignKeyConstraint(['id'], ['a.id'], primary_key=False)))
-
-Base.metadata.create_all()