连接字符串中的参考/查找密码

时间:2018-06-27 10:59:56

标签: python psycopg2

如何在不输入真实密码的情况下在连接详细信息中引用密码?

PWD = '1234'

try:
     con = psycopg2.connect("dbname = 'testdb' user = 'testuser' host = 
      'localhost' password = pwd")
 except:
       print ('I am unable to connect the database')

这不允许我连接,但以下内容将

try:
     con = psycopg2.connect("dbname = 'testdb' user = 'testuser' host = 
      'localhost' password = '1234'")
 except:
       print ('I am unable to connect the database')

0 个答案:

没有答案
相关问题