From 8489cb31e9b7ecdae2c7d95efcfddf79353b3b8c Mon Sep 17 00:00:00 2001 From: Cinabre Date: Wed, 16 Dec 2020 23:09:21 +0100 Subject: [PATCH] chapter_read_manuel/get_last_read pour mettre des chapitres en "lu" --- reading.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 reading.py diff --git a/reading.py b/reading.py new file mode 100644 index 0000000..6cf3ada --- /dev/null +++ b/reading.py @@ -0,0 +1,43 @@ +import sqlite3, sys +from database import * + +conn = sqlite3.connect('database.db') +cursor = conn.cursor() + + + + +def get_last_read(uid, mid): + cursor.execute("SELECT chap FROM readings WHERE uid = '{}' AND mid = '{}';".format(uid, mid) ) + rows = cursor.fetchall() + return rows[0][0] + + +def chapter_read_manual(uid, mid, chap): + username = get_dbusername(uid) + title = get_dbtitle(mid) + print("User : %s" % username) + print("Manga : %s" % mid) + print("Chapter : %s" % str(chap)) + rows = cursor.fetchall() + print("Last Chap: %s " % get_last_dread(uid, mid) ) + + if str(get_last_read(uid, mid)) == str(chap) : + print("Vous avez deja lu ce chapitre") + else : + print("Vous n'avez pas vu le chapitre {} du manga {}".format(chap, username)) + cursor.execute("UPDATE readings SET chap = '{}' WHERE mid = '{}' AND uid = '{}';".format(chap, mid, uid) ) + conn.commit() + # cursor.execute("SELECT password FROM users WHERE username = '%s' ;") + #cursor.execute("INSERT INTO manga(id, title, author, url, chap, img) VALUES(:id, :title, :author, :url, :chap, :img)") + + +def main(): + input("") + chapter_read_manual(1, 31477, 2) + + + + +if __name__ == '__main__': + main()