ogn-python/ogn/commands/database.py

33 wiersze
791 B
Python
Czysty Zwykły widok Historia

from ogn.model import Base
from manager import Manager
manager = Manager()
2015-11-24 07:20:28 +00:00
from ogn.collect.fetchddb import update_ddb_from_ogn, update_ddb_from_file
2015-11-15 18:31:58 +00:00
@manager.command
def init():
"""Initialize the database."""
from ogn.commands.dbutils import engine
Base.metadata.create_all(engine)
print("Done.")
@manager.command
2015-11-24 07:20:28 +00:00
def update_ddb_ogn():
"""Update devices with data from ogn."""
print("Updating ddb data...")
2015-11-24 07:20:28 +00:00
result = update_ddb_from_ogn.delay()
counter = result.get()
print("Imported %i devices." % counter)
@manager.command
def update_ddb_file():
"""Update devices with data from local file."""
print("Updating ddb data...")
result = update_ddb_from_file.delay()
counter = result.get()
2015-11-15 11:10:20 +00:00
print("Imported %i devices." % counter)