Compare commits

...

5 commits
v4 ... main

Author SHA1 Message Date
Magnus Åhall
aa1ead78e1 Bumped to v5 2024-04-24 16:32:51 +02:00
Magnus Åhall
9367bab359 Better descriptions when extracting 2024-04-24 16:32:41 +02:00
2b240d873b Update README.md 2024-04-23 19:08:44 +00:00
2e4b71e688 Update README.md 2024-04-23 19:08:14 +00:00
Magnus Åhall
45ccbe091c Added readme 2024-04-23 21:07:13 +02:00
2 changed files with 14 additions and 3 deletions

11
README.md Normal file
View file

@ -0,0 +1,11 @@
# Usage
pgsplit takes a PostgreSQL dump with multiple databases through STDIN and extracts them to the current directory, named with the database name and an .sql extension.
`pgsplit -list` prints the database names contained in the SQL dump.
`pgsplit` extracts all databases.
`pgsplit -include-all -except foo -except bar` extracts all databases except for foo and bar.
`pgsplit -exclude-all -except foo -except bar` extracts only databases foo and bar.

View file

@ -9,7 +9,7 @@ import (
"slices" "slices"
) )
const VERSION = "v4" const VERSION = "v5"
const MAXLINE = 1048576 const MAXLINE = 1048576
type Db struct { type Db struct {
@ -68,11 +68,11 @@ func main() {
dbName := dbMatch[1] dbName := dbMatch[1]
db = NewDb(dbName) db = NewDb(dbName)
if (flagIncludeAll && slices.Contains(flagExcept, dbName)) || (flagExcludeAll && !slices.Contains(flagExcept, dbName)) { if (flagIncludeAll && slices.Contains(flagExcept, dbName)) || (flagExcludeAll && !slices.Contains(flagExcept, dbName)) {
fmt.Printf("Skipping %s\n", dbName) fmt.Printf("Skipping %s\n", dbName)
continue continue
} }
fmt.Printf("Database %s\n", db.Name) fmt.Printf("Extracting %s\n", db.Name)
if flagList { if flagList {
continue continue
} }