Created
April 20, 2016 20:34
-
-
Save wuerges/d0f9c36af86b5f6df49bbc073c913d92 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
import os,sqlite3 | |
con=sqlite3.connect('dic.db') | |
cur=con.cursor() | |
cur.execute(''' | |
create table if not exists Palavras( | |
Palavra TEXT INTEGER, | |
Significado TEXT INTEGER | |
) | |
''') | |
con.commit() | |
def Palavra(): | |
palavra=raw_input("Qual a palavra?") | |
significado=raw_input("Qual o significado?") | |
cur.execute(''' | |
insert into Palavras(Palavra,Significado)values(?,?) | |
''',(palavra,significado)) | |
con.commit() | |
def Pesquisa(): | |
palavra=raw_input("Qual a palavra?\n") | |
cur.execute("select Palavra, Significado from Palavras where Palavra=?",(palavra, )) | |
con.commit() | |
campo=cur.fetchall() | |
for (palavra, significado) in campo: | |
print "Palavra:", palavra | |
print "Significado:", significado | |
a=input("1-Pesquisar\n2-Cadastrar nova palavra\n") | |
if a==1: | |
Pesquisa() | |
if a==2: | |
Palavra() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment