Commit 416716cc authored by Raquel's avatar Raquel 💬

week4, day1

parent 6e91fc49
.idea
.DS_Store
.sqlite3
from create_new_TODO import *
from delete_TODOS import *
from list_all_TODOS import *
from search_TODOS import *
def TODO_app():
print("Press \'h\' for help menu")
print("Press \'a\' to add a new TODO item to the list")
print("Press \'r\' to remove an item from the list")
print("Press \'l\' to look up an item on the list")
print("Press \'q\' to quit")
while True:
user_to_do = input("What do you want to do?")
if user_to_do == "a":
create_new_todo()
elif user_to_do == "r":
delete_TODO()
elif user_to_do == "s":
list_all()
elif user_to_do == "l":
search()
elif user_to_do == "h":
TODO_app()
elif user_to_do == "q":
break
print("goodbye")
print(TODO_app())
\ No newline at end of file
import sqlite3
conn = sqlite3.connect('./TODOapp.sqlite')
c = conn.cursor()
import datetime
def create_new_todo():
user_add = str(input("what do you want to add?"))
timestamp = datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S')
print(timestamp)
sql= f'''
INSERT INTO app
(content, created)
VALUES
("{user_add}", "{timestamp}");
'''
c.execute(sql)
conn.commit()
conn.close()
#print(create_new_todo())
import sqlite3
conn = sqlite3.connect('./TODOapp.sqlite')
c = conn.cursor()
def delete_TODO():
user_delete = str(input("type the item you want to delete"))
sql= f'''
DELETE FROM app
WHERE content == "{user_delete}"
'''
c.execute(sql)
conn.commit()
#print(delete_TODO())
\ No newline at end of file
import sqlite3
conn = sqlite3.connect('./TODOapp.sqlite')
c = conn.cursor()
def list_all():
sql = f'''
SELECT
*
FROM
app
ORDER BY
created ASC
;'''
c.execute(sql)
all_rows = c.fetchall()
print("Current TODOs: ")
for row in all_rows:
print(row)
#print (list_all())
\ No newline at end of file
name: SQLexercises
dependencies:
- python==3.7
- pip:
- django==2.2.1
\ No newline at end of file
import sqlite3
conn = sqlite3.connect('./TODOapp.sqlite')
c = conn.cursor()
def search():
user_search = str(input("type the item ID you want to look up"))
sql = f'''
SELECT
todo_id, content, created
FROM
app
WHERE
todo_id == "{user_search}"
'''
c.execute(sql)
row = c.fetchone()
print("The TODO you selected is:", row)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment