Advertisement
Guest User

Conect db python

a guest
Oct 10th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. import psycopg2
  2.  
  3. # print "Content-type: text\html"
  4. # print
  5. conn = psycopg2.connect("dbname='alunos'user='postgres'host='localhost'password='postgres'");
  6. c = conn.cursor()
  7. c.execute("SELECT estado FROM informacoes WHERE nome = 'fabio'")
  8. records = c.fetchall()
  9.  
  10. # import pprint
  11. # pprint.pprint(records)
  12. print(records)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement