我想用python列表获得Postgresql
服务器中所有数据库的列表。
基本上,我想在另一个数据库中创建这些
但我没能拿到。在
这就是我试过的
config_read = {
'host':'psql-002',
'database':'tesdb',
'user':'pguser',
'port':'5432',
'password':'mypass'
}
class ExportPSQL():
def __init__(self):
try:
conn = psycopg2.connect(**config_read)
self.conn = conn
except:
print "Eror Connecting database"
def run(self):
# Get a list of databases with :
db_command=" psql -h localhost -U pguser tesdb -c '\l'"
db_list = os.popen(db_command)
解决方案中缺少的是读取和解析从
psql
获得的信息:以超级用户的身份使用^{} 和{a2}完成所有操作
如果只想复制架构,那么使用
schema-only
参数。在将其还原到另一个群集
^{pr2}$相关问题 更多 >
编程相关推荐