Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save lsabiao/fa04c32306e0adc7784de55a0da162e4 to your computer and use it in GitHub Desktop.

Select an option

Save lsabiao/fa04c32306e0adc7784de55a0da162e4 to your computer and use it in GitHub Desktop.
OK, python3
# -*- 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()
@lsabiao
Copy link
Copy Markdown
Author

lsabiao commented Aug 26, 2016

Retirei o unicode, como pedido :)

@lsabiao
Copy link
Copy Markdown
Author

lsabiao commented Aug 26, 2016

print do python3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment