More work on native gui. Make data editable.

This commit is contained in:
thooge committed 2026-10-29 18:59:21 +01:00
1 parent 5641e1706f
commit 7aa5d2af3b
43 files changed
+2686 -1037

No files matched your search

+9 -2
View File
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: WTFPL
import MySQLdb
import secrets
from gettext import pgettext
@@ -50,6 +52,11 @@ class Database:
def is_connected(self):
return self.conn.open
def is_encrypted(self):
self.cur.execute("SHOW SESSION STATUS LIKE 'Ssl_cipher'")
row = self.cur.fetchone()
return (row and row[1])
def get_timestamp(self):
self.cur.execute("SELECT CURRENT_TIMESTAMP")
return self.cur.fetchone()[0]
@@ -64,13 +71,13 @@ class Database:
def load_enum(self, table, column):
"""
Load an enum directly from a database table and provide it as a
Load an enum or set directly from a database table and provide it as a
dictionary for use in, for example, selection lists.
"""
sql = (
"SELECT TRIM(TRAILING ')' FROM SUBSTRING(column_type,6)) "
"FROM information_schema.columns "
"WHERE table_schema=DATABASE() AND table_name=%s AND column_name=%s AND data_type='enum'"
"WHERE table_schema=DATABASE() AND table_name=%s AND column_name=%s AND data_type IN ('enum','set')"
)
self.cur.execute(sql, (table, column))
row = self.cur.fetchone()