Work on native gui code

This commit is contained in:
2026-07-16 15:18:21 +02:00
parent 3a8233e930
commit a92ff1a5de
4 changed files with 107 additions and 5 deletions
+33
View File
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
import MySQLdb.cursors
class Equipment():
fields = ('vid' 'ename', 'shortname', 'model', 'ecat', 'serial', 'supplier',
'manufacturer', 'purchdate', 'price', 'weight', 'remarks', 'flags')
def __init__(self, dbconn, eid=None):
self.conn = dbconn
self.dcur = dbconn.cursor(MySQLdb.cursors.DictCursor)
self.remarks = None
self.data = {} # for old/new checks
def load(self):
sql = (
"SELECT {}".format(', '.join(self.fields))
"FROM equipment "
"WHERE eid=%s"
)
self.dcur.execute(sql, (self.eid,))
self.data = self.dcur.fetchone()
if self.data:
for field in self.fields:
setattr(self, field, self.data.get(field))
else:
for field in self.fields:
setattr(self, field, None)
def save(self):
pass