目的是让两个简单的类代表数据库中已经存在的两个相关表。
代码是:
from pony.orm import *
db = Database()
class System(db.Entity):
_table_ = 'some', 'systems'
system_id = PrimaryKey(int, auto=True)
structures = Set('Structure')
class Structure(db.Entity):
_table_ = 'some', 'structures'
structure_id = PrimaryKey(int, auto=True)
system_id = Required(int)
system = Required(System)
db.bind(...)
db.generate_mapping(create_tables=False)
我试图遵循我在文档中看到的方法,但是执行上面的代码给了我:
psycopg2.ProgrammingError:列结构。系统不存在
第 1 行:...ctures"."structure_id", "structures"."system_id", "structure...提示:也许您的意思是引用列“structures.system_id”。
这里缺少什么?