Advertisement
Guest User

cadastro banco

a guest
Oct 11th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. import psycopg2
  2.  
  3. # print "Content-type: text\html"
  4. # print
  5. conn = psycopg2.connect("dbname='dbafa'user='postgres'host='localhost'password='postgres'");
  6. cur = conn.cursor()
  7.  
  8. cur.execute("insert into usuarios (nome_usuario, email_usuario, senha_usuario, cpf_usuario, cargo, nivel_permissao) values (%s, %s, %s, %s, %s, %s)", (us.pega_nome_usuario(),us.pega_email(),us.pega_senha(),us.pega_cpf(),us.pega_cargo(),us.pega_nivel_permissao()))
  9.                     # Make the changes to the database persistent
  10.                     conn.commit()
  11.                     cur.execute("select * from usuarios")
  12.                    
  13.                     print(cur.fetchall())
  14.  
  15.                     cur.close()
  16.                     conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement