aboutsummaryrefslogtreecommitdiffstats
path: root/database.py
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2022-05-07 21:04:34 +0000
committerjwansek <eddie.atten.ea29@gmail.com>2022-05-07 21:04:34 +0000
commit0a6a4956fe44ed77dba32ace075a185ac16a4ad3 (patch)
tree3e58629b7ec104c07f2d10581691ea6eddf62141 /database.py
parent022fa3780ad63b49cb50c1482aa1d598e27feac5 (diff)
downloadeda.gay-0a6a4956fe44ed77dba32ace075a185ac16a4ad3.tar.gz
eda.gay-0a6a4956fe44ed77dba32ace075a185ac16a4ad3.zip
Changed the ISO ordering system
Diffstat (limited to 'database.py')
-rw-r--r--database.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/database.py b/database.py
index 61ca2f7..ee3e3f0 100644
--- a/database.py
+++ b/database.py
@@ -17,20 +17,20 @@ class Database:
passwd:str = None
def __enter__(self):
- config = configparser.ConfigParser()
- config.read("edaweb.conf")
+ self.config = configparser.ConfigParser()
+ self.config.read("edaweb.conf")
if self.safeLogin:
self.__connection = pymysql.connect(
- **config["mysql"],
+ **self.config["mysql"],
charset = "utf8mb4"
)
else:
self.__connection = pymysql.connect(
user = self.user,
passwd = self.passwd,
- host = config["mysql"]["host"],
- db = config["mysql"]["db"],
+ host = self.config["mysql"]["host"],
+ db = self.config["mysql"]["db"],
charset = "utf8mb4"
)
return self
@@ -184,15 +184,19 @@ class Database:
return cursor.fetchone()[0]
def get_iso_cd_options(self):
- with self.__connection.cursor() as cursor:
- cursor.execute("SELECT name FROM isocds;")
- return [i[0] for i in cursor.fetchall()]
+ iso_dir = self.config.get("cds", "location")
+ return [
+ i
+ for i in os.listdir(iso_dir)
+ if os.path.splitext(i)[-1].lower() in [".iso"]
+ and os.path.getsize(os.path.join(iso_dir, i)) < self.config.getint("cds", "maxsize")
+ ]
def append_cd_orders(self, iso, email, house, street, city, county, postcode, name):
with self.__connection.cursor() as cursor:
cursor.execute("""
- INSERT INTO cd_orders (cd_id, email, house, street, city, county, postcode, name)
- VALUES ((SELECT cd_id FROM isocds WHERE name = %s), %s, %s, %s, %s, %s, %s, %s);
+ INSERT INTO cd_orders_2 (iso, email, house, street, city, county, postcode, name)
+ VALUES (%s, %s, %s, %s, %s, %s, %s, %s);
""", (iso, email, house, street, city, county, postcode, name))
id_ = cursor.lastrowid
self.__connection.commit()
@@ -250,4 +254,4 @@ if __name__ == "__main__":
import parser
with Database() as db:
# print(db.get_similar_thoughts("about me", 5))
- print(parser.parse_file("out.md"))
+ print(db.get_iso_cd_options())