Run MySQL and PostgreSQL queries and store result in CSV
Project description
# sql2csv
[](https://pypi.org/project/sql2csv)
[](https://travis-ci.org/gabfl/sql2csv)
[](https://codecov.io/gh/gabfl/sql2csv)
[](https://raw.githubusercontent.com/gabfl/sql2csv/master/LICENSE)
Run MySQL and PostgreSQL queries and store result in CSV
## Why sql2csv
`sql2csv` allows to export the result of MySQL and PostgreSQL queries to CSV files.
`sql2csv` helps exporting queries result from AWS RDS to CSV.
## Installation
```bash
pip3 install sql2csv
```
### Example
```bash
$ sql2csv --engine mysql \
--database my_db --user root --password "secret" \
--query "SELECT * FROM some_mysql_table" \
--out export.csv
# * Exporting rows...
# ...done
# * The result has been exported to export.csv.
$ cat export.csv
1,12,hello world,2018-12-01 12:23:12
2,15,hello,2018-12-05 12:18:12
3,18,world,2018-12-08 12:17:12
```
### Usage
```bash
sql2csv --help
usage: sql2csv [-h] [-e {mysql,postgresql}] [-H HOST] [-P PORT] -u USER
[-p PASSWORD] -d DATABASE -q QUERY [-o OUT] [-D DELIMITER]
[-Q QUOTECHAR]
optional arguments:
-h, --help show this help message and exit
-e {mysql,postgresql}, --engine {mysql,postgresql}
Database engine
-H HOST, --host HOST Database host
-P PORT, --port PORT Database port
-u USER, --user USER Database user
-p PASSWORD, --password PASSWORD Database password
-d DATABASE, --database DATABASE Database name
-q QUERY, --query QUERY SQL query
-o OUT, --out OUT CSV destination
-D DELIMITER, --delimiter DELIMITER CSV delimiter
-Q QUOTECHAR, --quotechar QUOTECHAR CSV quote character
```
[](https://pypi.org/project/sql2csv)
[](https://travis-ci.org/gabfl/sql2csv)
[](https://codecov.io/gh/gabfl/sql2csv)
[](https://raw.githubusercontent.com/gabfl/sql2csv/master/LICENSE)
Run MySQL and PostgreSQL queries and store result in CSV
## Why sql2csv
`sql2csv` allows to export the result of MySQL and PostgreSQL queries to CSV files.
`sql2csv` helps exporting queries result from AWS RDS to CSV.
## Installation
```bash
pip3 install sql2csv
```
### Example
```bash
$ sql2csv --engine mysql \
--database my_db --user root --password "secret" \
--query "SELECT * FROM some_mysql_table" \
--out export.csv
# * Exporting rows...
# ...done
# * The result has been exported to export.csv.
$ cat export.csv
1,12,hello world,2018-12-01 12:23:12
2,15,hello,2018-12-05 12:18:12
3,18,world,2018-12-08 12:17:12
```
### Usage
```bash
sql2csv --help
usage: sql2csv [-h] [-e {mysql,postgresql}] [-H HOST] [-P PORT] -u USER
[-p PASSWORD] -d DATABASE -q QUERY [-o OUT] [-D DELIMITER]
[-Q QUOTECHAR]
optional arguments:
-h, --help show this help message and exit
-e {mysql,postgresql}, --engine {mysql,postgresql}
Database engine
-H HOST, --host HOST Database host
-P PORT, --port PORT Database port
-u USER, --user USER Database user
-p PASSWORD, --password PASSWORD Database password
-d DATABASE, --database DATABASE Database name
-q QUERY, --query QUERY SQL query
-o OUT, --out OUT CSV destination
-D DELIMITER, --delimiter DELIMITER CSV delimiter
-Q QUOTECHAR, --quotechar QUOTECHAR CSV quote character
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sql2csv-1.0.tar.gz
(3.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sql2csv-1.0.tar.gz.
File metadata
- Download URL: sql2csv-1.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc4f2bfc6b48f91cd357da4a1da1f53574fda0b887598a040591858f10cff180
|
|
| MD5 |
ca3b2e0c4a0c2ead5d1477bf17d7325a
|
|
| BLAKE2b-256 |
39de8af3979ed5a0c0706fa2ee9a32540c9e02d920235b4b24cb51e4d3ff0a0f
|
File details
Details for the file sql2csv-1.0-py2.py3-none-any.whl.
File metadata
- Download URL: sql2csv-1.0-py2.py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1ebab852efaa151bfad8d93f30bb72e4470b32b55965909c5c37bf94fffb451
|
|
| MD5 |
7f944a27eba3e72c4ce4ef7622f07e22
|
|
| BLAKE2b-256 |
9f53cb3020c3f0cbf6e208dba183db936353ab3911eaca435f8740844d29161e
|