From 874ca12fcf789ff7a2474cdd2fcac09d8469b709 Mon Sep 17 00:00:00 2001 From: Sergio Date: Sat, 12 Aug 2023 18:09:47 +0200 Subject: [PATCH] =?UTF-8?q?A=C3=B1adido=20zxdb.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fbneo_roms_by_manufacturer.py | 2 +- zxdb.py | 39 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 zxdb.py diff --git a/fbneo_roms_by_manufacturer.py b/fbneo_roms_by_manufacturer.py index 04d1a42..a9b0028 100644 --- a/fbneo_roms_by_manufacturer.py +++ b/fbneo_roms_by_manufacturer.py @@ -34,7 +34,7 @@ for opt, arg in opts: opt_list = "yes" elif opt in ("-m", "--manufacturer"): opt_manufacturer = arg - elif opt == '-d': + elif opt in ("-d", "--dat"): opt_dat = arg elif opt in ("-c", "--copy"): opt_copy = "yes" diff --git a/zxdb.py b/zxdb.py new file mode 100644 index 0000000..d90ecba --- /dev/null +++ b/zxdb.py @@ -0,0 +1,39 @@ +import mysql.connector +from mysql.connector import errorcode + +config = { + 'user': 'root', + 'password': 'unJEPimbJddHP8', + 'host': '127.0.0.1', + 'database': 'zxdb', + 'raise_on_warnings': True +} + +try: + cnx = mysql.connector.connect(**config) +except mysql.connector.Error as err: + if err.errno == errorcode.ER_ACCESS_DENIED_ERROR: + print("Something is wrong with your user name or password") + elif err.errno == errorcode.ER_BAD_DB_ERROR: + print("Database does not exist") + else: + print(err) + + +cursor = cnx.cursor() + +query = ("SELECT id, title FROM entries " + "WHERE id BETWEEN %s AND %s") + +id_start = 1950 +id_end = 1980 + +cursor.execute(query, (id_start, id_end)) + +for (id, title) in cursor: + print("{} ({})".format(title, id)) + +cursor.close() +cnx.close() + +