Crates.io | copgy |
lib.rs | copgy |
version | 0.2.7 |
source | src |
created_at | 2024-01-18 02:41:27.872993 |
updated_at | 2024-09-02 19:47:23.662918 |
description | CLI utility tool for copying data between and executing SQL on PostgreSQL databases |
homepage | |
repository | https://github.com/knnmran/copgy |
max_upload_size | |
id | 1103746 |
size | 51,309 |
copgy is a CLI utility tool for copying data between and executing SQL on PostgreSQL databases.
Employ the readonly user approach when engaging with production databases to prevent inadvertent data loss.
cargo install copgy
copgy --source-db-url postgresql://host:5432/postgres --dest-db-url postgresql://host:5432/postgres single --source-sql 'select * from employees' --dest-table employees_tmp
copgy --source-db-url postgresql://host:5432/postgres --dest-db-url postgresql://host:5432/postgres script --file-path ~/Desktop/copgy.json
sample copgy.json
[
{
// execute on source db
"execute": {
"source_sql": "update employees set first_name = 'copgy' where emp_no = 0"
}
},
{
// execute on destination db
"execute": {
"dest_sql": "truncate employees_tmp"
}
},
{
// copy from source db to destination db
"copy": {
"source_sql": "select * from employees",
"dest_table": "employees_tmp"
}
}
]
Sample PostgreSQL connection string
postgresql://username:password@host:port/dbname