2021-02-18 06:04:30 +01:00
|
|
|
# standard imports
|
|
|
|
import logging
|
|
|
|
|
|
|
|
# local imports
|
2021-05-01 15:20:14 +02:00
|
|
|
from .list import (
|
|
|
|
list_transactions_mined,
|
|
|
|
list_transactions_account_mined,
|
|
|
|
add_transaction,
|
|
|
|
tag_transaction,
|
|
|
|
add_tag,
|
|
|
|
)
|
|
|
|
|
2021-02-18 06:04:30 +01:00
|
|
|
|
|
|
|
logg = logging.getLogger()
|
|
|
|
|
|
|
|
|
|
|
|
def dsn_from_config(config):
|
|
|
|
scheme = config.get('DATABASE_ENGINE')
|
|
|
|
if config.get('DATABASE_DRIVER') != None:
|
|
|
|
scheme += '+{}'.format(config.get('DATABASE_DRIVER'))
|
|
|
|
|
|
|
|
dsn = ''
|
|
|
|
if config.get('DATABASE_ENGINE') == 'sqlite':
|
|
|
|
dsn = '{}:///{}'.format(
|
|
|
|
scheme,
|
|
|
|
config.get('DATABASE_NAME'),
|
|
|
|
)
|
|
|
|
|
|
|
|
else:
|
|
|
|
dsn = '{}://{}:{}@{}:{}/{}'.format(
|
|
|
|
scheme,
|
|
|
|
config.get('DATABASE_USER'),
|
|
|
|
config.get('DATABASE_PASSWORD'),
|
|
|
|
config.get('DATABASE_HOST'),
|
|
|
|
config.get('DATABASE_PORT'),
|
|
|
|
config.get('DATABASE_NAME'),
|
|
|
|
)
|
|
|
|
logg.debug('parsed dsn from config: {}'.format(dsn))
|
|
|
|
return dsn
|
|
|
|
|