Connects to a MySQL database and exports selected data to JSON.
## Usage
```
mysql-to-json [-h] [-d DATABASE] [-H HOSTNAME] [-P PORT] [-u USER] [-p]
[-e QUERY]
optional arguments:
-h, --help show this help message and exit
-d DATABASE, --database DATABASE
MySQL database name.
-H HOSTNAME, --hostname HOSTNAME
MySQL host name.
-P PORT, --port PORT MySQL port number.
-u USER, --user USER MySQL username.
-p, --password Shh! It's a secret.
-e QUERY, --query QUERY
Query to run.
```
## Examples
All examples simple select all table information from `information_schema` and save it to `tables.json`
### Simple
This assumes we have full access to the mysql database from localhost.
```
$> mysql-to-json -e 'SELECT * FROM information_schema.tables' > tables.json
```
### Medium Complexity
This explicitly sets a user and asks for a password, while still connecting to localhost.
```
$> mysql-to-json -d mysql -u seth -p -e 'SELECT * FROM information_schema.tables' > tables.json
```
### All The Things!
This explicitly sets every command line option available.
```
$> mysql-to-json -h mydbserver.myhost.com -P 3306 -d mysql -u seth -p -e 'SELECT * FROM information_schema.tables' > tables.json
```
## Usage
```
mysql-to-json [-h] [-d DATABASE] [-H HOSTNAME] [-P PORT] [-u USER] [-p]
[-e QUERY]
optional arguments:
-h, --help show this help message and exit
-d DATABASE, --database DATABASE
MySQL database name.
-H HOSTNAME, --hostname HOSTNAME
MySQL host name.
-P PORT, --port PORT MySQL port number.
-u USER, --user USER MySQL username.
-p, --password Shh! It's a secret.
-e QUERY, --query QUERY
Query to run.
```
## Examples
All examples simple select all table information from `information_schema` and save it to `tables.json`
### Simple
This assumes we have full access to the mysql database from localhost.
```
$> mysql-to-json -e 'SELECT * FROM information_schema.tables' > tables.json
```
### Medium Complexity
This explicitly sets a user and asks for a password, while still connecting to localhost.
```
$> mysql-to-json -d mysql -u seth -p -e 'SELECT * FROM information_schema.tables' > tables.json
```
### All The Things!
This explicitly sets every command line option available.
```
$> mysql-to-json -h mydbserver.myhost.com -P 3306 -d mysql -u seth -p -e 'SELECT * FROM information_schema.tables' > tables.json
```
Metadata
Release files for mysql-to-json 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mysql-to-json-1.0.0.tar.gz | 2.7 kB | Details |
Release files / mysql-to-json-1.0.0.tar.gz
| Download URL | mysql-to-json-1.0.0.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5c2085709fe900cc412a5afd8a681bf65ec348fc1706cb3c73c69666af4b3c94
|
|
BLAKE2b-256 checksum How to use checksums |
cd142a1eb38a53a8288ad75155f49c9790a4d6de6505c4795b503c8a12cde898
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |