我有以下设置:
from flask import Flask
from sqlalchemy import Table, Column, Integer
from flask.ext.sqlalchemy import SQLAlchemy
import os
basedir = os.path.abspath(os.path.dirname(__file__))
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///offences.db'
offencedb = SQLAlchemy(app)
class Offences(offencedb.Model):
id = offencedb.Column(offencedb.Integer, primary_key=True)
nick = offencedb.Column(offencedb.String(100), unique=True)
offences = offencedb.Column(offencedb.Integer)
def __init__(self, nick, offences):
self.nick = nick
self.offences = offences
def __repr__(self):
return '<Nick %r>' % self.nick
如果我尝试通过以下方式使用模型:
offencesquery = Offences.query.filter_by(nick = nick).first()
我收到以下错误:
Error binding parameter 0 - probably unsupported type.
但是 nick 是一个字符串,数据库将 nick 列作为一个字符串......