The OSMPOL_SQL_DATABASE_URI was not being used by POL to connect
to the database. There was a hardcoded sqlite database name.
This change should now provide capability to the user to use any
SQL database engine supported by the peewee ORM (mysql/mariadb,
postgres, sqlite).
Signed-off-by: Benjamin Diaz <bdiaz@whitestack.com>
Change-Id: Iff406862fb3dfeb4453fb3213c94db6d62385d96
ENV OSMPOL_DATABASE_HOST mongo
ENV OSMPOL_DATABASE_PORT 27017
ENV OSMPOL_DATABASE_HOST mongo
ENV OSMPOL_DATABASE_PORT 27017
-ENV OSMPOL_SQL_DATABASE_URI sqlite:///mon_sqlite.db
+ENV OSMPOL_SQL_DATABASE_URI sqlite:///policy_module.db
ENV OSMPOL_LOG_LEVEL INFO
ENV OSMPOL_KAFKA_LOG_LEVEL WARN
ENV OSMPOL_LOG_LEVEL INFO
ENV OSMPOL_KAFKA_LOG_LEVEL WARN
CfgParam('OSMPOL_DATABASE_DRIVER', "mongo", six.text_type),
CfgParam('OSMPOL_DATABASE_HOST', "mongo", six.text_type),
CfgParam('OSMPOL_DATABASE_PORT', 27017, int),
CfgParam('OSMPOL_DATABASE_DRIVER', "mongo", six.text_type),
CfgParam('OSMPOL_DATABASE_HOST', "mongo", six.text_type),
CfgParam('OSMPOL_DATABASE_PORT', 27017, int),
- CfgParam('OSMPOL_SQL_DATABASE_URI', "sqlite:///mon_sqlite.db", six.text_type),
+ CfgParam('OSMPOL_SQL_DATABASE_URI', "sqlite:///policy_module.db", six.text_type),
CfgParam('OSMPOL_LOG_LEVEL', "INFO", six.text_type),
CfgParam('OSMPOL_KAFKA_LOG_LEVEL', "WARN", six.text_type),
]
CfgParam('OSMPOL_LOG_LEVEL', "INFO", six.text_type),
CfgParam('OSMPOL_KAFKA_LOG_LEVEL', "WARN", six.text_type),
]
import logging
from peewee import CharField, IntegerField, ForeignKeyField, Model, TextField, AutoField, DateTimeField
import logging
from peewee import CharField, IntegerField, ForeignKeyField, Model, TextField, AutoField, DateTimeField
-from playhouse.sqlite_ext import SqliteExtDatabase
+from playhouse.db_url import connect
from osm_policy_module.core.config import Config
log = logging.getLogger(__name__)
cfg = Config.instance()
from osm_policy_module.core.config import Config
log = logging.getLogger(__name__)
cfg = Config.instance()
-db = SqliteExtDatabase('policy_module.db')
+db = connect(cfg.OSMPOL_SQL_DATABASE_URI)