update movie database schema
This commit is contained in:
parent
64953ae402
commit
a632948414
|
@ -23,14 +23,10 @@ def setup(bot):
|
||||||
cur.execute("SELECT * FROM movie").fetchone()
|
cur.execute("SELECT * FROM movie").fetchone()
|
||||||
except OperationalError:
|
except OperationalError:
|
||||||
cur.execute("CREATE TABLE movie("
|
cur.execute("CREATE TABLE movie("
|
||||||
"movie_title TEXT NOT NULL PRIMARY KEY,"
|
"title TEXT PRIMARY KEY,"
|
||||||
"added_by TEXT DEFAULT 'UNKNOWN',"
|
"added_by TEXT,"
|
||||||
"added_date INTEGER DEFAULT (STRFTIME('%s', 'now')),"
|
"added_date INTEGER DEFAULT (STRFTIME('%s', 'now')),"
|
||||||
"times_watched INTEGER DEFAULT 0,"
|
"watched INTEGER DEFAULT 0"
|
||||||
"first_watched TEXT DEFAULT 'NA',"
|
|
||||||
"shitpost INTEGER DEFAULT 0,"
|
|
||||||
"theater_release_date TEXT,"
|
|
||||||
"bluray_release_date TEXT"
|
|
||||||
")")
|
")")
|
||||||
con.commit()
|
con.commit()
|
||||||
con.close()
|
con.close()
|
||||||
|
@ -140,8 +136,8 @@ def pickMovie(bot, trigger):
|
||||||
Picks a random movie title out of the database.
|
Picks a random movie title out of the database.
|
||||||
"""
|
"""
|
||||||
bot.memory['movie_lock'].acquire()
|
bot.memory['movie_lock'].acquire()
|
||||||
cur = bot.db.execute("SELECT movie_title FROM movie WHERE " + \
|
cur = bot.db.execute("SELECT title FROM movie WHERE "
|
||||||
"times_watched < 1 AND shitpost = 0 ORDER BY RANDOM() LIMIT 1;")
|
"watched = 0 ORDER BY RANDOM() LIMIT 1;")
|
||||||
movie = cur.fetchone()
|
movie = cur.fetchone()
|
||||||
bot.memory['movie_lock'].release()
|
bot.memory['movie_lock'].release()
|
||||||
|
|
||||||
|
@ -168,7 +164,7 @@ def addMovie(bot, trigger):
|
||||||
movie = ' '.join(trigger.args[1:])
|
movie = ' '.join(trigger.args[1:])
|
||||||
bot.memory['movie_lock'].acquire()
|
bot.memory['movie_lock'].acquire()
|
||||||
try:
|
try:
|
||||||
bot.db.execute("INSERT INTO movie (movie_title, added_by) VALUES(?,?)",
|
bot.db.execute("INSERT INTO movie (title, added_by) VALUES(?,?)",
|
||||||
(movie, trigger.nick))
|
(movie, trigger.nick))
|
||||||
confirm = f"Added movie: {movie}"
|
confirm = f"Added movie: {movie}"
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user