Skip to content

Fix csv_import data argument type #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand All @@ -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

Expand All @@ -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}
)
```
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "rushdb"
version = "1.5.0"
version = "1.5.1"
description = "RushDB Python SDK"
authors = ["RushDB Team <hi@rushdb.com>"]
license = "Apache-2.0"
Expand Down
8 changes: 4 additions & 4 deletions src/rushdb/api/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
Expand All @@ -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.
Expand Down Expand Up @@ -541,7 +541,7 @@ def import_csv(

payload = {
"label": label,
"data": csv_data,
"data": data,
"options": options or {"returnResult": True, "suggestTypes": True},
}

Expand Down
4 changes: 2 additions & 2 deletions tests/test_create_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down