PK! ̢00hello_todo/.cli.py.swpb0VIM 8.0j[i&xZmathiasGration~mathias/workspace/hello_todo/hello_todo/cli.pyutf-8 3210#"! UtpadjO&{j todo_lists()if __name__=='__main__': tod to todo_li todo_lists()if __name__=='__main__': print('%s|%s' % (name.center(20), desc.center(20))) desc = r['description'] or '' name = r['name'] for r in results: print('%s+%s' %('-' * 20, '-' * 20)) print('%s|%s' %('name'.center(20), 'description'.center(20))) results = db.get_all_todolist()def todo_lists():@click.command()from hello_todo import dbimport clickPK!e00hello_todo/.db.py.swpb0VIM 8.09e[%xZmathiasGration~mathias/workspace/hello_todo/hello_todo/db.py 3210#"! Utp4ad 4;\.-, ` _ ^  | ] U T E  l k j N : + s Z Y conn.execute("UPD conn.execute conn.ex conn.execute("UPDATE todo SET return results results = conn.execute("SELECT * FROM todo where todolist_id = ?", (todolist_id,)) with conn: conn = get_db()def get_todos(todolist_id): return results results = conn.execute("SELECT * FROM todolist") with conn: conn = get_db()def get_all_todolist(): conn.execute(query, (name, description, deadline, status, todolist_id)) with conn: """ values (?, ?, ?, ?, ?) INSERT INTO todo (name, description, deadline, status, todolist_id) query = """ conn = get_db() """ add a todo to a todolist """def add_todo(name, todolist_id, description=None, deadline=None, status=0): conn.execute("INSERT INTO todolist (name, description) values (?, ?)", (name, description)) with conn: conn = get_db() """ add a todolist """def add_todolist(name, description=None): conn.executescript(query.decode("utf-8")) query = pkg_resources.resource_string(__name__, "init_db.sql") conn = get_db() """ initialize database """def init_db(): return conn conn.row_factory = sqlite3.Row conn = sqlite3.connect(db_path) db_path = db_path or os.path.join(os.environ["HOME"], ".todolist.db") """ returns a connection to the database """def get_db(db_path=None):import pkg_resourcesimport osimport sqlite3PK!`00hello_todo/.init_db.sql.swpb0VIM 8.0c[%xZmathiasGration~mathias/workspace/hello_todo/hello_todo/init_db.sqlutf-8 3210#"! Utpad /[>;:'i2/); FOREIGN KEY (todolist_id) REFERENCES todolist (id) todolist_id INTEGER NOT NULL, status INTEGER, deadline VARCHAR(23), description VARCHAR(150), name VARCHAR(50) UNIQUE NOT NULL, id INTEGER PRIMARY KEY AUTOINCREMENT,CREATE TABLE todo(); description VARCHAR(150) name VARCHAR(50) UNIQUE NOT NULL, id INTEGER PRIMARY KEY AUTOINCREMENT,CREATE TABLE todolist (DROP TABLE IF EXISTS todo ;DROP TABLE IF EXISTS todolist ;PK! qhello_todo/__init__.py__version__ = '0.1.0' PK!9hello_todo/cli.pyimport click from hello_todo import db @click.command() def todo_lists(): results = db.get_all_todolist() print('%s|%s' %('name'.center(20), 'description'.center(20))) print('%s+%s' %('-' * 20, '-' * 20)) for r in results: name = r['name'] desc = r['description'] or '' print('%s|%s' % (name.center(20), desc.center(20))) if __name__=='__main__': todo_lists() PK!yDDhello_todo/db.pyimport sqlite3 import os import pkg_resources def get_db(db_path=None): """ returns a connection to the database """ db_path = db_path or os.path.join(os.environ["HOME"], ".todolist.db") conn = sqlite3.connect(db_path) conn.row_factory = sqlite3.Row return conn def init_db(): """ initialize database """ conn = get_db() query = pkg_resources.resource_string(__name__, "init_db.sql") conn.executescript(query.decode("utf-8")) def add_todolist(name, description=None): """ add a todolist """ conn = get_db() with conn: conn.execute("INSERT INTO todolist (name, description) values (?, ?)", (name, description)) def add_todo(name, todolist_id, description=None, deadline=None, status=0): """ add a todo to a todolist """ conn = get_db() query = """ INSERT INTO todo (name, description, deadline, status, todolist_id) values (?, ?, ?, ?, ?) """ with conn: conn.execute(query, (name, description, deadline, status, todolist_id)) def get_all_todolist(): conn = get_db() with conn: results = conn.execute("SELECT * FROM todolist") return results def get_todos(todolist_id): conn = get_db() with conn: results = conn.execute("SELECT * FROM todo where todolist_id = ?", (todolist_id,)) return results PK!u2hello_todo/init_db.sqlDROP TABLE IF EXISTS todolist ; DROP TABLE IF EXISTS todo ; CREATE TABLE todolist ( id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(50) UNIQUE NOT NULL, description VARCHAR(150) ); CREATE TABLE todo( id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(50) UNIQUE NOT NULL, description VARCHAR(150), deadline VARCHAR(23), status INTEGER, todolist_id INTEGER NOT NULL, FOREIGN KEY (todolist_id) REFERENCES todolist (id) ); PK!H.dz*.+hello_todo-0.1.2.dist-info/entry_points.txtN+I/N.,()*O/Hɏs2\..PK!H WX hello_todo-0.1.2.dist-info/WHEEL A н#Z."jm)Afb~ڠO68oF04UhoAf f4=4h0k::wXPK!Hv#hello_todo-0.1.2.dist-info/METADATAMK1 9*2;~EUVs`h9쿷Êޒ}dc |)G Z j, XZ^!`kFWo<|~7 0qǤ H^Ct!u R#q1g$[ݗ.a1~]މԷhYql\4ڟr0zzPե/PK!Ḩ Y!hello_todo-0.1.2.dist-info/RECORD}I@}(t dY6$Jۨ"fqj#w"kJ~갾HhuTv( ;mMwKjm 9FzVxyDŽݝ1kd9 ^H]VUÕm_WY5 W@c =;Ò*J |qχ.bTaT؏f8zpDNĺYڶ0~[=Ez7rq.B)&(C$ }[}-6'Ai)z'T;u^oGL+2Z/$[;=3Q:^f@}312/NAy#lԢwlQO;Z&<˓q*Sm5,&=[0='~ZdQt g;\=5/PtdǾ7=^=~fKW=wKG4] <EޓSĴ0fcGܙaoPK! ̢00hello_todo/.cli.py.swpPK!e0040hello_todo/.db.py.swpPK!`00g`hello_todo/.init_db.sql.swpPK! qhello_todo/__init__.pyPK!9hello_todo/cli.pyPK!yDDhello_todo/db.pyPK!u2!hello_todo/init_db.sqlPK!H.dz*.+&hello_todo-0.1.2.dist-info/entry_points.txtPK!H WX hello_todo-0.1.2.dist-info/WHEELPK!Hv#.hello_todo-0.1.2.dist-info/METADATAPK!Ḩ Y!>hello_todo-0.1.2.dist-info/RECORDPK