https://github.com/wmarquardt/cassandra-csv
A simple way to export cassandra query result to CSV format
https://github.com/wmarquardt/cassandra-csv
cassandra csv data python
Last synced: over 1 year ago
JSON representation
A simple way to export cassandra query result to CSV format
- Host: GitHub
- URL: https://github.com/wmarquardt/cassandra-csv
- Owner: wmarquardt
- License: mit
- Created: 2019-04-12T00:38:05.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-01-19T01:17:12.000Z (over 2 years ago)
- Last Synced: 2025-02-28T06:19:41.501Z (over 1 year ago)
- Topics: cassandra, csv, data, python
- Language: Python
- Size: 20.5 KB
- Stars: 6
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[](https://github.com/psf/black)
# Cassandra CSV
Python package to export cassandra query result to CSV format.
Cassandra `COPY` function does not export data with **WHERE** clause. If you need to export cassandra query result to CSV format, just read the documentation below.
## Install
```shell
$ pip install cassandra-csv
```
## Usage
```python
from cassandra.cluster import Cluster
from cassandracsv import CassandraCsv
cluster = Cluster()
cassandra_cluster = cluster.connect('database')
result = cassandra_cluster.execute("""SELECT foo FROM bar WHERE foobar=2""")
CassandraCsv.export(
result,
[options]
)
```
## Options
|Name| Type | Default | Description |
|--|--|--|--|
| **max_file_size** | int | 0 | max CSV file size (lines) the file will be splitted until complete entire resultset. Use 0 to export all result to just one file |
| **output_dir** | string | /tmp | full output path
| **filename** | string | export_file | file name (without extension)
| **separator** | string | , | string separator
| **with_header** | boolean | True | show file header (field name or alias, added direct on select using `as`)
| **create_subfolder** | boolean | False | create sulfolder to store files.