2023-11-19 18:45:25 +01:00
|
|
|
import random
|
|
|
|
import string
|
2023-11-19 15:52:48 +01:00
|
|
|
import sqlite3
|
|
|
|
|
2023-11-19 18:45:25 +01:00
|
|
|
def run_sqlite_command(*args):
|
2023-11-19 15:52:48 +01:00
|
|
|
"""Run a command against the database"""
|
2023-11-19 16:05:23 +01:00
|
|
|
con = sqlite3.connect("instance/partitioncloud.sqlite")
|
2023-11-19 15:52:48 +01:00
|
|
|
cur = con.cursor()
|
2023-11-19 18:45:25 +01:00
|
|
|
cur.execute(*args)
|
2023-11-19 15:52:48 +01:00
|
|
|
con.commit()
|
2023-11-19 18:45:25 +01:00
|
|
|
con.close()
|
|
|
|
|
|
|
|
def get_sqlite_data(*args):
|
|
|
|
"""Get data from the db"""
|
|
|
|
con = sqlite3.connect("instance/partitioncloud.sqlite")
|
|
|
|
cur = con.cursor()
|
|
|
|
data = cur.execute(*args)
|
|
|
|
new_data = [i for i in data]
|
|
|
|
con.close()
|
|
|
|
return new_data
|
|
|
|
|
|
|
|
def new_uuid():
|
|
|
|
return ''.join([random.choice(string.ascii_uppercase + string.digits) for _ in range(6)])
|
|
|
|
|
|
|
|
def format_uuid(uuid):
|
|
|
|
"""Format old uuid4 format"""
|
|
|
|
return uuid.upper()[:6]
|