mirror of
https://github.com/krateng/maloja.git
synced 2025-07-09 03:04:07 -04:00
Added meta table to database
This commit is contained in:
parent
d8e5f6552e
commit
e4bf26b86d
@ -1,4 +1,5 @@
|
|||||||
import sqlalchemy as sql
|
import sqlalchemy as sql
|
||||||
|
from sqlalchemy.dialects.sqlite import insert as sqliteinsert
|
||||||
import json
|
import json
|
||||||
import unicodedata
|
import unicodedata
|
||||||
import math
|
import math
|
||||||
@ -20,6 +21,13 @@ from doreah.regular import runhourly, runmonthly
|
|||||||
|
|
||||||
DBTABLES = {
|
DBTABLES = {
|
||||||
# name - type - foreign key - kwargs
|
# name - type - foreign key - kwargs
|
||||||
|
'_maloja':{
|
||||||
|
'columns':[
|
||||||
|
("key", sql.String, {'primary_key':True}),
|
||||||
|
("value", sql.String, {})
|
||||||
|
],
|
||||||
|
'extraargs':(),'extrakwargs':{}
|
||||||
|
},
|
||||||
'scrobbles':{
|
'scrobbles':{
|
||||||
'columns':[
|
'columns':[
|
||||||
("timestamp", sql.Integer, {'primary_key':True}),
|
("timestamp", sql.Integer, {'primary_key':True}),
|
||||||
@ -151,6 +159,29 @@ def connection_provider(func):
|
|||||||
wrapper.__innerfunc__ = func
|
wrapper.__innerfunc__ = func
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
@connection_provider
|
||||||
|
def get_maloja_info(keys,dbconn=None):
|
||||||
|
op = DB['_maloja'].select().where(
|
||||||
|
DB['_maloja'].c.key.in_(keys)
|
||||||
|
)
|
||||||
|
result = dbconn.execute(op).all()
|
||||||
|
|
||||||
|
info = {}
|
||||||
|
for row in result:
|
||||||
|
info[row.key] = row.value
|
||||||
|
return info
|
||||||
|
|
||||||
|
@connection_provider
|
||||||
|
def set_maloja_info(info,dbconn=None):
|
||||||
|
for k in info:
|
||||||
|
op = sqliteinsert(DB['_maloja']).values(
|
||||||
|
key=k, value=info[k]
|
||||||
|
).on_conflict_do_update(
|
||||||
|
index_elements=['key'],
|
||||||
|
set_={'value':info[k]}
|
||||||
|
)
|
||||||
|
dbconn.execute(op)
|
||||||
|
|
||||||
##### DB <-> Dict translations
|
##### DB <-> Dict translations
|
||||||
|
|
||||||
## ATTENTION ALL ADVENTURERS
|
## ATTENTION ALL ADVENTURERS
|
||||||
|
@ -302,15 +302,6 @@ data_dir = {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
### write down the last ran version
|
|
||||||
with open(pthj(dir_settings['state'],".lastmalojaversion"),"w") as filed:
|
|
||||||
filed.write(VERSION)
|
|
||||||
filed.write("\n")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### DOREAH CONFIGURATION
|
### DOREAH CONFIGURATION
|
||||||
|
|
||||||
from doreah import config
|
from doreah import config
|
||||||
@ -336,7 +327,8 @@ config(
|
|||||||
|
|
||||||
custom_css_files = [f for f in os.listdir(data_dir['css']()) if f.lower().endswith('.css')]
|
custom_css_files = [f for f in os.listdir(data_dir['css']()) if f.lower().endswith('.css')]
|
||||||
|
|
||||||
|
from ..database.sqldb import set_maloja_info
|
||||||
|
set_maloja_info({'last_run_version':VERSION})
|
||||||
|
|
||||||
# what the fuck did i just write
|
# what the fuck did i just write
|
||||||
# this spaghetti file is proudly sponsored by the rice crackers i'm eating at the
|
# this spaghetti file is proudly sponsored by the rice crackers i'm eating at the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user