Skip to content

Instantly share code, notes, and snippets.

@robin-wittler
robin-wittler / gist:1676017
Created January 25, 2012 12:19
fix for this
from flask.ext.sqlalchemy import SQLAlchemy
from sqlalchemy.interfaces import PoolListener
class SQLiteForeignKeysListener(PoolListener):
def connect(self, dbapi_con, con_record):
db_cursor = dbapi_con.execute('pragma foreign_keys=ON')
class StrictSQLAlchemy(SQLAlchemy):
@robin-wittler
robin-wittler / gist:1643718
Created January 19, 2012 23:33
example code where ForeignKey and type check fails for flask-sqlalchemy
#!/usr/bin/python
# -*- coding: utf-8 -*-
from flask import Flask
from flaskext.sqlalchemy import SQLAlchemy
from werkzeug.security import generate_password_hash
from werkzeug.security import check_password_hash
from sqlalchemy.orm.exc import NoResultFound
app = Flask(__name__)