【问题标题】:Display all databases names from a given ip, port, username and password using python使用 python 显示来自给定 ip、端口、用户名和密码的所有数据库名称
【发布时间】:2021-06-27 21:32:00
【问题描述】:

我需要显示所有找到的数据库名称。

我找到了从已知数据库获取信息的解决方案,但就我而言,我不知道“database_name.db”。

谁能帮帮我!

【问题讨论】:

标签: python mysql postgresql django-rest-framework


【解决方案1】:

好吧,你不必这样做:

psql -h localhost -U pguser -c '\l'

这样您将连接到默认数据库(称为 postgres)。 postgres 连接需要连接到数据库。 输出:

 数据库列表
   姓名 |所有者 |编码 |整理 |类型 |访问权限
------------+----------+----------+-------------+-- -----------+-----------
 我的测试数据库 |后勤 | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 |
 数据库 |后勤 | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 |
 后勤 |后勤 | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 |
 模板0 |后勤 | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 | =c/postgres +
           | | | | | postgres=CTc/postgres
 模板1 |后勤 | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 | =c/postgres +
           | | | | | postgres=CTc/postgres

【讨论】:

    猜你喜欢
    • 2017-10-13
    • 2016-12-04
    • 2018-07-17
    • 2018-07-27
    • 2014-02-26
    • 2016-01-31
    • 2018-02-13
    • 2016-02-05
    • 1970-01-01
    相关资源
    最近更新 更多