Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import psycopg2
- import psycopg2
- try:
- conn = psycopg2.connect("dbname='template1' user='dbuser' host='localhost'
- password='dbpass'")
- except:
- print "I am unable to connect to the database"
- cur = conn.cursor()
- cur.execute("""SELECT datname from pg_database""")
- rows = cur.fetchall()
- print "nShow me the databases:n"
- for row in rows:
- print " ", row[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement