feat: Implements auto-updating database table

- Automatically updates database table from old versions / Invitarr
 - Fancy text formatting to boost my ego
 - Removes synced variable from config, as we now sync always (guild-specific sync is automatic.)

task: gh-9
This commit is contained in:
Yoruio
2022-07-14 01:08:32 -06:00
parent 8375395bb8
commit 22c9bd1da9
6 changed files with 93 additions and 19 deletions

View File

@@ -1,6 +1,9 @@
import sqlite3
from app.bot.helper.dbupdater import check_table_version, update_table
DB_URL = 'app/config/app.db'
DB_TABLE = 'clients'
def create_connection(db_file):
""" create a database connection to a SQLite database """
@@ -26,7 +29,7 @@ def checkTableExists(dbcon, tablename):
conn = create_connection(DB_URL)
# Checking if table exists
if checkTableExists(conn, 'clients'):
if checkTableExists(conn, DB_TABLE):
print('Table exists.')
else:
conn.execute(
@@ -38,6 +41,8 @@ else:
PRIMARY KEY("id" AUTOINCREMENT)
);''')
update_table(conn, DB_TABLE)
def save_user_email(username, email):
if username and email:
conn.execute(f"""