我正在尝试使用geoalchemy2
. 根据那个链接似乎是可能的。
我认为我的问题来自自定义引擎。
到目前为止我所拥有的:
from flask_sqlalchemy import SQLAlchemy
from geoalchemy2 import Geometry
#and other imports...
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////Users/cricket/Documents/peas project/open-peas/localapp/test.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SQLALCHEMY_ECHO'] = True
db = SQLAlchemy(app)
class Polygon(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(64), unique=True)
point = db.Column(Geometry("POLYGON"))
@app.before_first_request
def init_request():
db.create_all()
当我启动脚本时,我收到以下消息:
cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) near "POLYGON": syntax error [SQL: '\nCREATE TABLE polygon (\n\tid INTEGER NOT NULL, \n\tname VARCHAR(64), \n\tpoint geometry(POLYGON,-1), \n\tPRIMARY KEY (id), \n\tUNIQUE (name)\n)\n\n'] (Background on this error at: http://sqlalche.me/e/e3q8)
知道我该如何解决吗?