繁体   English   中英

Postgres模式与Pony ORM

[英]Postgres schemas with Pony ORM

如何选择在PonyORM中使用哪种postgres架构?

我试图使用一个只有一个名为“test1”的架构的权限的角色登录,但它将我连接到公共架构。 所以,我删除了公共架构,然后它给了我一个错误:

 ProgrammingError: no schema has been selected to create in
 LINE 1: CREATE TABLE "customers" (

你可以用两种可能的方式做到这一点。

首先是指定您的连接

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 = ...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM