【发布时间】:2019-07-08 18:56:42
【问题描述】:
我正在尝试使用 geoalchemy2 和 sqlalchemy 创建一个包含地理数据的表,遵循geoalchemy ORM tutorial
我在我使用的架构上安装了 postgis 扩展。我正在连接的用户是架构的所有者。
当我运行 python 代码时:
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String
from geoalchemy2 import Geography
import src.config as config
Base = declarative_base()
class Lake(Base):
__tablename__ = 'lake'
__table_args__ = ({'schema': 'geobox'})
id = Column(Integer, primary_key=True)
country_iso_code = Column(String(2))
zone_code = Column(String(45))
zone_type = Column(String(45))
zone_test = Column(Geography('POINT'))
from sqlalchemy import create_engine
engine = create_engine('postgres://{user}:{pwd}@{host}:{port}/{database}'.format(
user=config.DbConfig().username,
pwd=config.DbConfig().password,
host=config.DbConfig().host,
port=config.DbConfig().port,
database=config.DbConfig().database), echo=True)
Lake.__table__.create(engine)
我得到错误:
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) type "geography" does not exist
我在这里错过了什么?
【问题讨论】:
标签: postgresql sqlalchemy postgis