mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2025-06-21 16:41:08 +00:00
Add api keys db path as env var (#1)
* Add API Keys DB path to command & env vars * Create API Keys DB directory if not exists before sqlite connection & Add docker-compose example
This commit is contained in:
parent
393eebe235
commit
752d2aae2c
7 changed files with 48 additions and 5 deletions
|
@ -1,13 +1,18 @@
|
|||
import os
|
||||
import sqlite3
|
||||
import uuid
|
||||
import requests
|
||||
from expiringdict import ExpiringDict
|
||||
from app.default_values import DEFAULT_ARGUMENTS as DEFARGS
|
||||
|
||||
DEFAULT_DB_PATH = "api_keys.db"
|
||||
DEFAULT_DB_PATH = DEFARGS['API_KEYS_DB_PATH']
|
||||
|
||||
|
||||
class Database:
|
||||
def __init__(self, db_path=DEFAULT_DB_PATH, max_cache_len=1000, max_cache_age=30):
|
||||
db_dir = os.path.dirname(db_path)
|
||||
if not db_dir == "" and not os.path.exists(db_dir):
|
||||
os.makedirs(db_dir)
|
||||
self.db_path = db_path
|
||||
self.cache = ExpiringDict(max_len=max_cache_len, max_age_seconds=max_cache_age)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue