This is using SQLAlchemy version 0.6.0, Python 2.6.5.
The following program:
from sqlalchemy import Table, Column, Integer, String, MetaData
from sqlalchemy import ForeignKey, create_engine
metadata = MetaData()
table1 = Table('table1', metadata,
Column('id', Integer, primary_key = True),
Column('fid', Integer, ForeignKey('
table2.id')),
sqlite_autoincrement = True)
table2 = Table('table2', metadata,
Column('id', Integer, primary_key = True),
Column('stuff', String), sqlite_autoincrement = True)
engine = create_engine('sqlite://', echo = True)
metadata.create_all(engine)
Generates the following commands:
CREATE TABLE table2 (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
stuff VARCHAR
)
CREATE TABLE table1 (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
fid INTEGER,
,
FOREIGN KEY(fid) REFERENCES table2 (id)
)
The extra comma in the Table1 creation causes a syntax error. This
seems to be a function of declaring a foreign key when also setting
sqlite_autoincrement = True. What am I doing wrong?
--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to
sqlal...@googlegroups.com.
To unsubscribe from this group, send email to
sqlalchemy+...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.