From 4f3ef1b1025d000bc0cf0b8db7c57f69f6a7c36d Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Wed, 18 May 2016 15:42:46 -0600 Subject: [PATCH] Add simple script for inserting ofxsources This only adds one institution that I care about, AFCU, but could be extended to use the data from ofxhome.com. I downloaded the data from them but found two problems. One, they work in XML, which I don't feel like parsing, but two and far more importantly, they provide the second piece of data I need, the routing number for the bank. That sucks. So it's likely that if this project does well we will have more data than them. --- bin/update-ofxsource | 25 +++++++++++++++++++++++++ vanth/main.py | 18 ++++++++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) create mode 100755 bin/update-ofxsource diff --git a/bin/update-ofxsource b/bin/update-ofxsource new file mode 100755 index 0000000..4871543 --- /dev/null +++ b/bin/update-ofxsource @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +import logging +import uuid + +import vanth.main +import vanth.tables + +LOGGER = logging.getLogger(__name__) +def main(): + vanth.main.setup_logging() + config = vanth.main.get_config() + engine = vanth.main.create_db_connection(config) + + new_uuid = uuid.uuid4() + query = vanth.tables.OFXSource.insert().values( # pylint: disable=no-value-for-parameter + uuid = str(new_uuid), + name = 'America First Credit Union', + fid = '54324', + bankid = '324377516', + ) + results = engine.execute(query) + LOGGER.info("Created OFX source %s", results.inserted_primary_key[0]) + +if __name__ == '__main__': + main() diff --git a/vanth/main.py b/vanth/main.py index c7760cf..7eece88 100644 --- a/vanth/main.py +++ b/vanth/main.py @@ -11,11 +11,13 @@ import vanth.tables LOGGER = logging.getLogger(__name__) -def create_application(config): - sepiida.log.setup_logging() +def create_db_connection(config): engine = chryso.connection.Engine(config.db, vanth.tables) chryso.connection.store(engine) + return engine +def create_application(config): + create_db_connection(config) LOGGER.info("Starting up vanth version %s", vanth.version.VERSION) application = vanth.server.create_app(config) @@ -23,11 +25,19 @@ def create_application(config): return application -def main(): +def setup_logging(): logging.getLogger().setLevel(logging.DEBUG) logging.basicConfig() - config = sepiida.config.load('/etc/vanth.yaml', vanth.config.SPECIFICATION) + sepiida.log.setup_logging() + +def get_config(): + return sepiida.config.load('/etc/vanth.yaml', vanth.config.SPECIFICATION) + +def main(): + setup_logging() + config = get_config() + application = create_application(config) try: host = os.getenv('HOST', 'localhost')