Browse Source

Fix coverage2sql-db-manage to read config

This commit fixes coverage2sql-db-manage to read config file correctly.
In the previous version, coverage2sql-db-manage command doesn't work.
I'm not sure when it didn't work, though.

Change-Id: If3bb93a661a723b0ff0eedf9f0ed84c2af8d88e6
Masayuki Igawa 2 years ago
parent
commit
ff8f03ece5
No account linked to committer's email address
2 changed files with 5 additions and 1 deletions
  1. 2
    1
      coverage2sql/db/api.py
  2. 3
    0
      coverage2sql/migrations/cli.py

+ 2
- 1
coverage2sql/db/api.py View File

@@ -38,7 +38,8 @@ def setup():
38 38
 
39 39
     pool_size = CONF.database.max_pool_size
40 40
     pool_recycle = CONF.database.idle_timeout
41
-    if not pool_size and not pool_recycle:
41
+    if db_uri.get_backend_name() == 'sqlite' or (not pool_size
42
+                                                 and not pool_recycle):
42 43
         engine = create_engine(db_uri)
43 44
     else:
44 45
         engine = create_engine(db_uri,

+ 3
- 0
coverage2sql/migrations/cli.py View File

@@ -23,6 +23,7 @@ from alembic import util as alembic_util
23 23
 from oslo_config import cfg
24 24
 
25 25
 from coverage2sql.db import api as db_api
26
+from coverage2sql import shell
26 27
 
27 28
 HEAD_FILENAME = 'HEAD'
28 29
 
@@ -177,7 +178,9 @@ def main():
177 178
     config.set_main_option('script_location',
178 179
                            'coverage2sql:migrations')
179 180
     config.coverage2sql_config = CONF
181
+    CONF.register_cli_opts(shell.DATABASE_OPTS, group='database')
180 182
     CONF()
183
+    db_api.get_session()
181 184
     CONF.command.func(config, CONF.command.name)
182 185
 
183 186
 if __name__ == "__main__":

Loading…
Cancel
Save