【发布时间】:2015-08-20 13:17:28
【问题描述】:
我正在尝试使用以下变量连接到 Postgres 数据库:
cs = "dbname=%s user=%s password=%s host=%s port=%s",(dn,du,dp,dh,dbp)
con = None
con = psycopg2.connect(cs)
但是我收到错误消息:
TypeError: argument 1 must be string, not tuple
我需要能够在连接字符串中使用变量。有谁知道如何做到这一点?
【问题讨论】:
标签: python postgresql psycopg2