https://github.com/nrnrk/psql-splitter
Split a postgres sql file into multiple files
https://github.com/nrnrk/psql-splitter
golang postgresql sql
Last synced: 5 months ago
JSON representation
Split a postgres sql file into multiple files
- Host: GitHub
- URL: https://github.com/nrnrk/psql-splitter
- Owner: nrnrk
- License: bsd-3-clause
- Created: 2019-07-21T17:50:54.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-20T14:40:16.000Z (about 5 years ago)
- Last Synced: 2024-06-21T03:12:54.809Z (about 2 years ago)
- Topics: golang, postgresql, sql
- Language: Go
- Homepage:
- Size: 7.35 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# psql-splitter
Split a (postgres) sql file into multiple files by a chunk of statements.
## Installation
`go get github.com/nrnrk/psql-splitter`
## Usage
`psql-splitter split {sql file} [-n {split by}]`
For example, if you split `sample.sql` like
```
SELECT * FROM users;
SELECT * FROM others;
INSERT INTO users
VALUES (12111, 'Mike', TRUE);
```
by 2 statements, execute the following command.
`psql-splitter split sample.sql -n 2`
The 2 following files are generated.
sample-aa.sql
```
SELECT * FROM users;
SELECT * FROM others;
```
sample-ab.sql
```
INSERT INTO users
VALUES (12111, 'Mike', TRUE);
```
You can confirm this split by `diff` command like
```
cat sample-* |diff sample.sql -
```
## License
This software includes the work that is distributed in the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).