mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-03-11 01:36:11 +01:00
add db config at startup
This commit is contained in:
parent
844e11edeb
commit
4336613028
1 changed files with 19 additions and 0 deletions
|
@ -52,6 +52,25 @@ def bundle_vendored():
|
||||||
with open(outputpath, "w") as f:
|
with open(outputpath, "w") as f:
|
||||||
f.write(output)
|
f.write(output)
|
||||||
|
|
||||||
|
async def get_admin_settings():
|
||||||
|
from lnbits.extensions.admin.models import Admin
|
||||||
|
|
||||||
|
async with core_db.connect() as conn:
|
||||||
|
|
||||||
|
if conn.type == SQLITE:
|
||||||
|
exists = await conn.fetchone(
|
||||||
|
"SELECT * FROM sqlite_master WHERE type='table' AND name='admin'"
|
||||||
|
)
|
||||||
|
elif conn.type in {POSTGRES, COCKROACH}:
|
||||||
|
exists = await conn.fetchone(
|
||||||
|
"SELECT * FROM information_schema.tables WHERE table_name = 'admin'"
|
||||||
|
)
|
||||||
|
if not exists:
|
||||||
|
return False
|
||||||
|
|
||||||
|
row = await conn.fetchone("SELECT * from admin")
|
||||||
|
|
||||||
|
return Admin(**row) if row else None
|
||||||
|
|
||||||
async def migrate_databases():
|
async def migrate_databases():
|
||||||
"""Creates the necessary databases if they don't exist already; or migrates them."""
|
"""Creates the necessary databases if they don't exist already; or migrates them."""
|
||||||
|
|
Loading…
Add table
Reference in a new issue