added defaults for some database columns that really should have them
This commit is contained in:
parent
f5f183b45b
commit
cb30496d62
1 changed files with 4 additions and 5 deletions
9
web.py
9
web.py
|
@ -23,7 +23,6 @@ settings = {
|
|||
db = mysql.connector.connect(user=cfg['dbuser'], password=cfg['dbpass'], database=cfg['dbname'])
|
||||
c = db.cursor()
|
||||
dc = db.cursor(dictionary=True)
|
||||
# MariaDB [curiousgreg]> DESCRIBE data;
|
||||
# +---------------------+---------------+------+-----+------------------------------------------------+-------+
|
||||
# | Field | Type | Null | Key | Default | Extra |
|
||||
# +---------------------+---------------+------+-----+------------------------------------------------+-------+
|
||||
|
@ -37,11 +36,11 @@ dc = db.cursor(dictionary=True)
|
|||
# | cc | tinytext | YES | | NULL | |
|
||||
# | ccavi | varchar(128) | YES | | https://lynnesbian.space/res/ceres/cc-smol.png | |
|
||||
# | latest_post | tinytext | YES | | NULL | |
|
||||
# | last_check | tinytext | YES | | NULL | |
|
||||
# | time_between_checks | int(11) | YES | | NULL | |
|
||||
# | last_check | int(11) | NO | | 0 | |
|
||||
# | time_between_checks | int(11) | NO | | 1 | |
|
||||
# | 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 VARCHAR(4096) DEFAULT %s, PRIMARY KEY(username, instance))", (json.dumps(settings),))
|
||||
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 INT DEFAULT 0 NOT NULL, time_between_checks INT DEFAULT %s NOT NULL, settings VARCHAR(4096) DEFAULT %s, PRIMARY KEY(username, instance))", (cfg['min_time_between_checks'], json.dumps(settings),))
|
||||
|
||||
app = Flask(cfg['name'])
|
||||
app.secret_key = cfg['flask_key']
|
||||
|
@ -237,7 +236,7 @@ def ccc_c():
|
|||
return redirect('/cc_connect/code?invalid')
|
||||
for item in ['cc', 'ccavi']:
|
||||
session[item] = session['cctemp'][item]
|
||||
c.execute("UPDATE data SET cc = %s, ccavi = %s, latest_post = %s, time_between_checks = %s, last_check = %s WHERE username = %s AND instance = %s", (session['cc'], session['ccavi'], session['cctemp']['latest_post'], 1, 0, session['username'], session['instance']))
|
||||
c.execute("UPDATE data SET cc = %s, ccavi = %s, latest_post = %s, WHERE username = %s AND instance = %s", (session['cc'], session['ccavi'], session['cctemp']['latest_post'], session['username'], session['instance']))
|
||||
db.commit()
|
||||
del session['cctemp']
|
||||
return redirect('/cc_connect/complete')
|
||||
|
|
Loading…
Reference in a new issue