Connects to a MySQL database and exports selected data to JSON.
Project description
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
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mysql-to-json-1.0.0.tar.gz
(2.7 kB
view details)
File details
Details for the file mysql-to-json-1.0.0.tar.gz
.
File metadata
- Download URL: mysql-to-json-1.0.0.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c2085709fe900cc412a5afd8a681bf65ec348fc1706cb3c73c69666af4b3c94 |
|
MD5 | 34252cf7c643186d62fd90f7ef959101 |
|
BLAKE2b-256 | cd142a1eb38a53a8288ad75155f49c9790a4d6de6505c4795b503c8a12cde898 |