Advertisement
Guest User

Untitled

a guest
Feb 12th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. # 03_create_data_sql.py
  2. import sqlite3
  3.  
  4. conn = sqlite3.connect('clientes.db')
  5. cursor = conn.cursor()
  6.  
  7. # inserindo dados na tabela
  8. cursor.execute("""
  9. INSERT INTO clientes (nome, idade, cpf, email, fone, cidade, uf, criado_em)
  10. VALUES ('Regis', 35, '00000000000', 'regis@email.com', '11-98765-4321', 'Sao Paulo', 'SP', '2014-06-08')
  11. """)
  12.  
  13. cursor.execute("""
  14. INSERT INTO clientes (nome, idade, cpf, email, fone, cidade, uf, criado_em)
  15. VALUES ('Aloisio', 87, '11111111111', 'aloisio@email.com', '98765-4322', 'Porto Alegre', 'RS', '2014-06-09')
  16. """)
  17.  
  18. cursor.execute("""
  19. INSERT INTO clientes (nome, idade, cpf, email, fone, cidade, uf, criado_em)
  20. VALUES ('Bruna', 21, '22222222222', 'bruna@email.com', '21-98765-4323', 'Rio de Janeiro', 'RJ', '2014-06-09')
  21. """)
  22.  
  23. cursor.execute("""
  24. INSERT INTO clientes (nome, idade, cpf, email, fone, cidade, uf, criado_em)
  25. VALUES ('Matheus', 19, '33333333333', 'matheus@email.com', '11-98765-4324', 'Campinas', 'SP', '2014-06-08')
  26. """)
  27.  
  28. # gravando no bd
  29. conn.commit()
  30.  
  31. print('Dados inseridos com sucesso.')
  32.  
  33. conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement