Forked from anonymous/gist:870ca4f8bc8fdf6c9975038aa69802f4
Last active
August 26, 2016 02:28
-
-
Save lsabiao/fa04c32306e0adc7784de55a0da162e4 to your computer and use it in GitHub Desktop.
OK, python3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import sqlite3 | |
from alimentos import * | |
connection = sqlite3.connect('bancoalimentos.db') | |
c = connection.cursor() | |
def create_table(): | |
c.execute('CREATE TABLE IF NOT EXISTS alimentos (id integer, alimentos text, \ | |
valor real)') | |
create_table() | |
def dados(): | |
''' | |
c.execute("INSERT INTO alimentos VALUES(1,'banana',10.5)") | |
c.execute("INSERT INTO alimentos VALUES(2,'batata',10.3)") | |
c.execute("INSERT INTO alimentos VALUES(3,'barata',10.4)") | |
''' | |
for i in range(len(alimentos)): | |
print (lista[i], alimentos[lista[i]) | |
c.execute("INSERT INTO alimentos(id, alimentos, valor) VALUES(?,?,?)",(i,lista[i],alimentos[lista[i]])) | |
connection.commit() | |
dados() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Retirei o unicode, como pedido :)