SqlAlchemy extension: https://pythonhosted.org/Flask-SQLAlchemy/index.html
and i want to setup the engine with customer configuration using the parameters here: http://docs.sqlalchemy.org/en/rel_0_9/core/engines.html
I'm using the way described on Flask-SqlAlchemy documentation:
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True)
email = db.Column(db.String(120), unique=True)
def __init__(self, username, email):
self.username = username
self.email = email
def __repr__(self):
return '<User %r>' % self.username
EDIT: How can I pass the following engine parameters in this kind of configuration:
isolation_level = 'AUTOCOMMIT', encoding='latin1', echo=True
method: SQLAlchemy() doesn't take these as arguments.
it's an open issue: https://github.com/mitsuhiko/flask-sqlalchemy/issues/166
you can try this
class SQLiteAlchemy(SQLAlchemy):
def apply_driver_hacks(self, app, info, options):
options.update({
'isolation_level': 'AUTOCOMMIT',
'encoding': 'latin1',
'echo': True
})
super(SQLiteAlchemy, self).apply_driver_hacks(app, info, options)
db = SQLiteAlchemy(app)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With