如何选择要在PonyORM中使用的postgres模式?
我尝试使用一个只有权访问一个模式"test1“的角色登录,但它将我连接到公共模式。因此,我删除了公共模式,然后它给了我一个错误:
ProgrammingError: no schema has been selected to create in
LINE 1: CREATE TABLE "customers" (发布于 2018-08-03 17:32:50
您可以通过两种可能的方法来完成此任务。
首先是指定您的连接
db = Database()
... # models definition
pg = dict(
provider='postgres',
user='username',
password='pwd',
host='localhost',
database='db',
options='-c search-path=SCHEMA NAME') # here you specify default schema
db.bind(**pg)
db.generate_mapping(create_tables=True)第二个是为实体指定_table_选项
class Person(db.Entity):
_table_ = ('schemaname', 'tablename')
attribute = ...https://stackoverflow.com/questions/48772576
复制相似问题