Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
db_name for sqlite data nodes should be the file name (#512)
Browse files Browse the repository at this point in the history
* fix: db_name to sqlite should be the file name

(cherry picked from commit e44388d)

* Update version.json

---------

Co-authored-by: Jean-Robin <[email protected]>
  • Loading branch information
trgiangdo and jrobinAV authored Mar 9, 2023
1 parent f139284 commit baee7d0
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/taipy/core/config/data_node_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def _configure_sql_table(
id (str): The unique identifier of the new SQL data node configuration.
db_username (str): The database username.
db_password (str): The database password.
db_name (str): The database name.
db_name (str): The database name, or the name of the SQLite database file.
db_host (str): The database host. The default value is _"localhost"_.
db_engine (str): The database engine. Possible values are _"sqlite"_, _"mssql"_, _"mysql"_, or
_"postgresql"_.
Expand Down Expand Up @@ -665,7 +665,7 @@ def _configure_sql(
id (str): The unique identifier of the new SQL data node configuration.
db_username (str): The database username.
db_password (str): The database password.
db_name (str): The database name.
db_name (str): The database name, or the name of the SQLite database file.
db_engine (str): The database engine. Possible values are _"sqlite"_, _"mssql"_, _"mysql"_, or
_"postgresql"_.
db_port (int): The database port. The default value is 1433.
Expand Down
8 changes: 4 additions & 4 deletions src/taipy/core/data/abstract_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ def __init__(
owner_id: Optional[str] = None,
parent_ids: Optional[Set[str]] = None,
last_edit_date: Optional[datetime] = None,
edits: List[Edit] = None,
version: str = None,
edits: Optional[List[Edit]] = None,
version: Optional[str] = None,
validity_period: Optional[timedelta] = None,
edit_in_progress: bool = False,
properties: Dict = None,
properties: Optional[Dict] = None,
):
if properties is None:
properties = {}
Expand Down Expand Up @@ -175,7 +175,7 @@ def _conn_string(self) -> str:
return f"postgresql+psycopg2://{username}:{password}@{host}:{port}/{db_name}?{extra_args_str}"
elif engine == self.__ENGINE_SQLITE:
path = self.properties.get(self.__SQLITE_PATH_KEY, "")
return os.path.join("sqlite:///", path, f"{db_name}.sqlite3")
return os.path.join("sqlite:///", path, f"{db_name}")

raise UnknownDatabaseEngine(f"Unknown engine: {engine}")

Expand Down
12 changes: 6 additions & 6 deletions src/taipy/core/data/data_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def __init__(
owner_id: Optional[str] = None,
parent_ids: Optional[Set[str]] = None,
last_edit_date: Optional[datetime] = None,
edits: List[Edit] = None,
version: str = None,
edits: Optional[List[Edit]] = None,
version: Optional[str] = None,
validity_period: Optional[timedelta] = None,
edit_in_progress: bool = False,
**kwargs,
Expand Down Expand Up @@ -359,18 +359,18 @@ def lock_edition(self):
_warn_deprecated("lock_edition", suggest="lock_edit")
self.lock_edit()

def unlock_edit(self, at: datetime = None, job_id: JobId = None):
def unlock_edit(self, at: Optional[datetime] = None, job_id: Optional[JobId] = None):
"""Unlocks the data node modification.
Parameters:
at (datetime): Deprecated.
job_id (JobId^): Deprecated.
at (Optional[datetime]): Deprecated.
job_id (Optional[JobId^]): Deprecated.
Note:
The data node can be locked with the method `(DataNode.)lock_edit()^`.
"""
self.edit_in_progress = False # type: ignore

def unlock_edition(self, at: datetime = None, job_id: JobId = None):
def unlock_edition(self, at: Optional[datetime] = None, job_id: Optional[JobId] = None):
"""Deprecated. Use `(DataNode.)unlock_edit()^` instead."""
_warn_deprecated("unlock_edition", suggest="unlock_edit")
self.unlock_edit()
Expand Down
8 changes: 4 additions & 4 deletions src/taipy/core/data/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SQLDataNode(_AbstractSQLDataNode):
- _"db_username"_ `(str)`: The database username.
- _"db_password"_ `(str)`: The database password.
- _"db_name"_ `(str)`: The database name.
- _"db_name"_ `(str)`: The database name, or the name of the SQLite database file.
- _"db_engine"_ `(str)`: The database engine. Possible values are _"sqlite"_, _"mssql"_, _"mysql"_, or
_"postgresql"_.
- _"db_port"_ `(int)`: The database port. The default value is 1433.
Expand All @@ -74,11 +74,11 @@ def __init__(
owner_id: Optional[str] = None,
parent_ids: Optional[Set[str]] = None,
last_edit_date: Optional[datetime] = None,
edits: List[Edit] = None,
version: str = None,
edits: Optional[List[Edit]] = None,
version: Optional[str] = None,
validity_period: Optional[timedelta] = None,
edit_in_progress: bool = False,
properties: Dict = None,
properties: Optional[Dict] = None,
):
if properties is None:
properties = {}
Expand Down
8 changes: 4 additions & 4 deletions src/taipy/core/data/sql_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SQLTableDataNode(_AbstractSQLDataNode):
- _"db_username"_ `(str)`: The database username.
- _"db_password"_ `(str)`: The database password.
- _"db_name"_ `(str)`: The database name.
- _"db_name"_ `(str)`: The database name, or the name of the SQLite database file.
- _"db_host"_ `(str)`: The database host. The default value is _"localhost"_.
- _"db_engine"_ `(str)`: The database engine. For now, the accepted values are _"sqlite"_, _"mssql"_,
_"mysql"_, or _"postgresql"_.
Expand All @@ -76,11 +76,11 @@ def __init__(
owner_id: Optional[str] = None,
parent_ids: Optional[Set[str]] = None,
last_edit_date: Optional[datetime] = None,
edits: List[Edit] = None,
version: str = None,
edits: Optional[List[Edit]] = None,
version: Optional[str] = None,
validity_period: Optional[timedelta] = None,
edit_in_progress: bool = False,
properties: Dict = None,
properties: Optional[Dict] = None,
):
if properties is None:
properties = {}
Expand Down
2 changes: 1 addition & 1 deletion src/taipy/core/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"major": 2, "minor": 1, "patch": 2}
{"major": 2, "minor": 1, "patch": 3}
4 changes: 2 additions & 2 deletions tests/core/data/test_sql_data_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def single_write_query_builder(data):
class TestSQLDataNode:
__pandas_properties = [
{
"db_name": "taipy",
"db_name": "taipy.sqlite3",
"db_engine": "sqlite",
"read_query": "SELECT * FROM foo",
"write_query_builder": my_write_query_builder_with_pandas,
Expand All @@ -60,7 +60,7 @@ class TestSQLDataNode:

__modin_properties = [
{
"db_name": "taipy",
"db_name": "taipy.sqlite3",
"db_engine": "sqlite",
"read_query": "SELECT * FROM foo",
"write_query_builder": my_write_query_builder_with_modin,
Expand Down

0 comments on commit baee7d0

Please sign in to comment.