diff options
Diffstat (limited to 'cli.py')
-rwxr-xr-x | cli.py | 25 |
1 files changed, 8 insertions, 17 deletions
@@ -5,20 +5,14 @@ from orator import DatabaseManager, Model import orator from pyble import * +import config import re import time -def setup_database(filename): - """Setup a connection with an SQLite database in filename""" - config = { - 'default': 'sqlite', - 'sqlite': { - 'driver': 'sqlite', - 'database': filename, - } - } - db = DatabaseManager(config) +def setup_database(): + """Setup a connection with the database""" + db = DatabaseManager(config.DATABASES) Model.set_connection_resolver(db) return db @@ -28,12 +22,10 @@ def cli(): pass @cli.command() -@click.argument('filename', type=click.Path()) -def init(filename): +def init(): """Initialise an SQLite database in filename, and create tables""" click.echo('Initialising pyble database...') - db = setup_database(filename) - setup_tables(db) + db = setup_database() click.echo('Inserting common book names...') setup_fill_alternative_book_names(db) click.echo('Done.') @@ -103,10 +95,9 @@ def load_biblehub(db, f): @cli.command() @click.option('--type', required=True) @click.argument('filename', type=click.Path()) -@click.argument('dbname', type=click.Path()) -def load(type, filename, dbname): +def load(type, filename): """Load external data into the database""" - db = setup_database(dbname) + db = setup_database() if type == 'biblehub': with open(filename) as f: load_biblehub(db, f) |