Commit 217241748424e9d73844d3f311ef8897be3b2f80
1 parent
7e08aa0c
Exists in
master
and in
4 other branches
Fix mysql_lesia_uri import exception
Showing
3 changed files
with
9 additions
and
3 deletions
Show diff stats
app/commands/commands.py
@@ -2,6 +2,7 @@ import sys | @@ -2,6 +2,7 @@ import sys | ||
2 | import click | 2 | import click |
3 | import random | 3 | import random |
4 | 4 | ||
5 | +from flask import current_app | ||
5 | from sqlalchemy.exc import OperationalError | 6 | from sqlalchemy.exc import OperationalError |
6 | from sqlalchemy.sql import func | 7 | from sqlalchemy.sql import func |
7 | from sqlalchemy.ext.automap import automap_base | 8 | from sqlalchemy.ext.automap import automap_base |
@@ -10,8 +11,6 @@ from sqlalchemy import create_engine | @@ -10,8 +11,6 @@ from sqlalchemy import create_engine | ||
10 | 11 | ||
11 | from app.models import db, User, Agent, Service, Project, Capacity, Period, Charge | 12 | from app.models import db, User, Agent, Service, Project, Capacity, Period, Charge |
12 | 13 | ||
13 | -from db_config import mysql_lesia_uri | ||
14 | - | ||
15 | from . import bp | 14 | from . import bp |
16 | 15 | ||
17 | 16 | ||
@@ -23,7 +22,7 @@ def feed_from_lesia(): | @@ -23,7 +22,7 @@ def feed_from_lesia(): | ||
23 | """ | 22 | """ |
24 | Base = automap_base() | 23 | Base = automap_base() |
25 | 24 | ||
26 | - engine = create_engine(mysql_lesia_uri) | 25 | + engine = create_engine(current_app.config['LESIA_AGENTS_DB_URI']) |
27 | 26 | ||
28 | # reflect the tables | 27 | # reflect the tables |
29 | try: | 28 | try: |
pdc_config.py
@@ -25,6 +25,12 @@ class Config(object): | @@ -25,6 +25,12 @@ class Config(object): | ||
25 | SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \ | 25 | SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \ |
26 | 'sqlite:///' + os.path.join(root_dir, 'pdc_app.db') | 26 | 'sqlite:///' + os.path.join(root_dir, 'pdc_app.db') |
27 | 27 | ||
28 | + try: | ||
29 | + LESIA_AGENTS_DB_URI = mysql_lesia_uri | ||
30 | + except NameError: | ||
31 | + LESIA_AGENTS_DB_URI = os.environ.get('LESIA_AGENTS_DB_URI') or \ | ||
32 | + 'sqlite:///' + os.path.join(root_dir, 'lesia.db') | ||
33 | + | ||
28 | with open(os.path.join(root_dir, 'VERSION.txt')) as version_file: | 34 | with open(os.path.join(root_dir, 'VERSION.txt')) as version_file: |
29 | VERSION = version_file.read().strip() | 35 | VERSION = version_file.read().strip() |
30 | 36 |
resources/db_config.py
@@ -39,6 +39,7 @@ POSTGRESTEST = { | @@ -39,6 +39,7 @@ POSTGRESTEST = { | ||
39 | } | 39 | } |
40 | postgres_test_uri = 'postgresql://%(user)s:%(pw)s@%(host)s:%(port)s/%(db)s' % POSTGRESTEST | 40 | postgres_test_uri = 'postgresql://%(user)s:%(pw)s@%(host)s:%(port)s/%(db)s' % POSTGRESTEST |
41 | 41 | ||
42 | +# The lesia mysql agents database | ||
42 | MYSQL_LESIA = { | 43 | MYSQL_LESIA = { |
43 | 'user': 'mysql', | 44 | 'user': 'mysql', |
44 | 'pw': 'mysql', | 45 | 'pw': 'mysql', |