Created
September 12, 2018 12:00
-
-
Save eliassoares/43456a7b866263cfc41d78cee5e4fa58 to your computer and use it in GitHub Desktop.
List all databases Postgres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conn = psycopg2.connect("user='eliassoares' host='127.0.0.1' password='mysecretpassword'") | |
cur = conn.cursor() | |
cur.execute('SELECT datname FROM pg_database WHERE datistemplate = false;') | |
rows = cur.fetchall() | |
print(rows) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment