Avaiga / taipy-core

A Python library to build powerful and customized data-driven back-end applications.
Apache License 2.0
38 stars 17 forks source link

BUG-Can not change the db_location of SQL repository #787

Closed trgiangdo closed 1 year ago

trgiangdo commented 1 year ago

Description The SQL engine is always called when init taipy, so that whatever the db_location is set by the Config.configure_core() method, the db_location will always be "None".

The problem is caused by:

In _sql_repository.py, there is an import

from .db._init_db import init_db

which called to the db._init_db.py file, which has an import

from ._sql_session import engine

which the engine is a global variable and will always be generated at the import.

How to reproduce

import taipy as tp
from taipy import Config

Config.configure_core(repository_type="sql", repository_properties={"db_location": "test.sqlite"})
tp.Core().run()

After running the code (with some configuration if possible), there will be a "None" file which is a SQLite database.

Expected behavior "db_location" should be properly assigned as the path of the SQLite database.