psycopg2中连接字符串中能够直接设置schema么?

everfight
  • 2.5k

python脚本中运行sql中一直要加入架构名xjd,想问下是否可以直接在连接字符串中规定好要连接的schema?

原始连接json

{
    "configs": [
        {
            "dbname": "postgres",
            "user": "postgres",
            "password": "123456",
            "host": "127.0.0.1",
            "port": "5432"
        },
        {
            "dbname": "mercury",
            "user": "mercury",
            "password": "123456",
            "host": "127.0.0.1",
            "port": "5432"
        }
    ]
}

在参数里加入: "schema": "xjd"
报错:
psycopg2.ProgrammingError: invalid dsn: invalid connection option "schema"

尝试看psycopg2没看懂,想问下如何将架构这个参数加进连接字符串中?

回复
阅读 4.2k
1 个回答
宣传栏