Added default settings to DB

This commit is contained in:
Lynne Megido 2018-11-13 12:55:18 +10:00
parent 042acb6b1a
commit c451be78df
Signed by: lynnesbian
GPG key ID: FB7B970303ACE499

10
web.py
View file

@ -24,9 +24,9 @@ db = mysql.connector.connect(user=cfg['dbuser'], password=cfg['dbpass'], databas
c = db.cursor() c = db.cursor()
dc = db.cursor(dictionary=True) dc = db.cursor(dictionary=True)
# MariaDB [curiousgreg]> DESCRIBE data; # MariaDB [curiousgreg]> DESCRIBE data;
# +---------------------+--------------+------+-----+------------------------------------------------+-------+ # +---------------------+---------------+------+-----+------------------------------------------------+-------+
# | Field | Type | Null | Key | Default | Extra | # | Field | Type | Null | Key | Default | Extra |
# +---------------------+--------------+------+-----+------------------------------------------------+-------+ # +---------------------+---------------+------+-----+------------------------------------------------+-------+
# | username | varchar(64) | NO | PRI | NULL | | # | username | varchar(64) | NO | PRI | NULL | |
# | instance | varchar(128) | NO | PRI | NULL | | # | instance | varchar(128) | NO | PRI | NULL | |
# | password | tinytext | NO | | NULL | | # | password | tinytext | NO | | NULL | |
@ -39,9 +39,9 @@ dc = db.cursor(dictionary=True)
# | latest_post | tinytext | YES | | NULL | | # | latest_post | tinytext | YES | | NULL | |
# | last_check | tinytext | YES | | NULL | | # | last_check | tinytext | YES | | NULL | |
# | time_between_checks | int(11) | YES | | NULL | | # | time_between_checks | int(11) | YES | | NULL | |
# | settings | longtext | YES | | NULL | | # | settings | varchar(4096) | YES | | {'cw': False} | |
# +---------------------+--------------+------+-----+------------------------------------------------+-------+ # +---------------------+---------------+------+-----+------------------------------------------------+-------+
c.execute("CREATE TABLE IF NOT EXISTS `data` (username VARCHAR(64) NOT NULL, instance VARCHAR(128) NOT NULL, password TINYTEXT NOT NULL, avi TEXT NOT NULL, secret TINYTEXT NOT NULL, client_id VARCHAR(128) NOT NULL, client_secret TINYTEXT NOT NULL, cc TINYTEXT, ccavi VARCHAR(128) DEFAULT 'https://lynnesbian.space/res/ceres/cc-smol.png', latest_post TINYTEXT, last_check TINYTEXT, time_between_checks INT, settings LONGTEXT, PRIMARY KEY(username, instance))") c.execute("CREATE TABLE IF NOT EXISTS `data` (username VARCHAR(64) NOT NULL, instance VARCHAR(128) NOT NULL, password TINYTEXT NOT NULL, avi TEXT NOT NULL, secret TINYTEXT NOT NULL, client_id VARCHAR(128) NOT NULL, client_secret TINYTEXT NOT NULL, cc TINYTEXT, ccavi VARCHAR(128) DEFAULT 'https://lynnesbian.space/res/ceres/cc-smol.png', latest_post TINYTEXT, last_check TINYTEXT, time_between_checks INT, settings VARCHAR(4096) DEFAULT \"{}\", PRIMARY KEY(username, instance))".format(settings))
app = Flask(cfg['name']) app = Flask(cfg['name'])
app.secret_key = cfg['flask_key'] app.secret_key = cfg['flask_key']