小编fat*_*n13的帖子

SqlAlchemy 自动映射不生成 Base.classes.[table_name]

我有一个从 csv 导入的现有 sqlite 数据库文件。我尝试使用 sqlalchemy 自动映射 db 文件。但它总是给我...

回溯(最近一次调用最后):文件“”,第 1 行,文件“C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\util_collections.py” ,第 212 行,在getattr中 引发 AttributeError(key) AttributeError:destinationservices

任何帮助表示赞赏。

from flask import Flask
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)

from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from sqlalchemy import create_engine

Base = automap_base()

# engine, suppose it has two tables 'user' and 'address' set up
engine = create_engine("sqlite:///destServ.db")

# reflect the tables
Base.prepare(engine, reflect=True)

# mapped classes are now created with names by default …
Run Code Online (Sandbox Code Playgroud)

python sqlite sqlalchemy

4
推荐指数
1
解决办法
3396
查看次数

标签 统计

python ×1

sqlalchemy ×1

sqlite ×1