I am Python 2.7.3, and SQLite version 3.7.9. I added the code you guys 
mentioned above to the env.py script:

from __future__ import with_statement
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config

# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)
......
from sqlalchemy.engine import Engine
from sqlalchemy import event

@event.listens_for(Engine, "connect")
def set_sqlite_pragma(dbapi_connection, connection_record):
    cursor = dbapi_connection.cursor()
    cursor.execute("PRAGMA foreign_keys=ON")
    cursor.close()

def run_migrations_offline():

...

g
Then I ran 'alembic revision --autogenerate' and 'alembic upgrade head' 
commands. My testing tables were created as usual. When I logged in sqlite by 
'sqlite3 mydb', and checked 'PRAGMA foreign_keys', it is still 0. There is no 
change yet. What is wrong? 

Thanks a lot! 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/sQmT2g72nCgJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to