Advertisement
Guest User

Conect db python

a guest
Oct 10th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 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. # c.execute("insert into informacoes (nome,estado,populacao) values ('fabio','pr', 123);
  9. ")
  10. records = c.fetchall()
  11.  
  12. # import pprint
  13. # pprint.pprint(records)
  14. print(records)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement