From 022d86b1feec4d8777f017a0d0185cc9d48f8e26 Mon Sep 17 00:00:00 2001 From: Artemiy Vereshchinskiy Date: Wed, 11 Jun 2025 11:28:09 +0700 Subject: [PATCH] Fix csv_import data argument type --- README.md | 8 ++++---- pyproject.toml | 2 +- src/rushdb/api/records.py | 8 ++++---- tests/test_create_import.py | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d32e277..086f27a 100644 --- a/README.md +++ b/README.md @@ -644,7 +644,7 @@ Imports records from CSV data. def import_csv( self, label: str, - csv_data: Union[str, bytes], + data: str, options: Optional[Dict[str, bool]] = None, transaction: Optional[Transaction] = None ) -> List[Dict[str, Any]] @@ -653,7 +653,7 @@ def import_csv( **Arguments:** - `label` (str): Label for imported records -- `csv_data` (Union[str, bytes]): CSV data to import +- `data` (Union[str, bytes]): CSV data to import - `options` (Optional[Dict[str, bool]]): Import options - `transaction` (Optional[Transaction]): Optional transaction object @@ -665,14 +665,14 @@ def import_csv( ```python # Import records from CSV -csv_data = """name,age,department,role +data = """name,age,department,role John Doe,30,Engineering,Senior Engineer Jane Smith,28,Product,Product Manager Bob Wilson,35,Engineering,Tech Lead""" records = db.records.import_csv( label="EMPLOYEE", - csv_data=csv_data, + data=data, options={"returnResult": True, "suggestTypes": True} ) ``` diff --git a/pyproject.toml b/pyproject.toml index 4a97d1c..3c055a8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "rushdb" -version = "1.5.0" +version = "1.5.1" description = "RushDB Python SDK" authors = ["RushDB Team "] license = "Apache-2.0" diff --git a/src/rushdb/api/records.py b/src/rushdb/api/records.py index 1763274..7c311d5 100644 --- a/src/rushdb/api/records.py +++ b/src/rushdb/api/records.py @@ -499,7 +499,7 @@ def find( def import_csv( self, label: str, - csv_data: Union[str, bytes], + data: str, options: Optional[Dict[str, bool]] = None, transaction: Optional[Transaction] = None, ) -> List[Dict[str, Any]]: @@ -511,8 +511,8 @@ def import_csv( Args: label (str): The label/type to assign to all records created from the CSV. - csv_data (Union[str, bytes]): The CSV content to import. Can be provided - as a string or bytes object. + data (Union[str, bytes]): The CSV content to import. Can be provided + as a string. options (Optional[Dict[str, bool]], optional): Configuration options for the import operation. Available options: - returnResult (bool): Whether to return the created records data. Defaults to True. @@ -541,7 +541,7 @@ def import_csv( payload = { "label": label, - "data": csv_data, + "data": data, "options": options or {"returnResult": True, "suggestTypes": True}, } diff --git a/tests/test_create_import.py b/tests/test_create_import.py index 057536f..f08fe7b 100644 --- a/tests/test_create_import.py +++ b/tests/test_create_import.py @@ -200,12 +200,12 @@ def test_transaction_rollback(self): def test_import_csv(self): """Test importing data from CSV""" - csv_data = """name,age,department,role,salary + data = """name,age,department,role,salary John Doe,30,Engineering,Senior Engineer,120000 Jane Smith,28,Product,Product Manager,110000 Bob Wilson,35,Engineering,Tech Lead,140000""" - self.client.records.import_csv("EMPLOYEE", csv_data) + self.client.records.import_csv("EMPLOYEE", data) def test_search_result_integration(self): """Test SearchResult integration with find operations"""