https://github.com/cao7113/dba
db toolbox for geeks
https://github.com/cao7113/dba
db sql
Last synced: about 2 months ago
JSON representation
db toolbox for geeks
- Host: GitHub
- URL: https://github.com/cao7113/dba
- Owner: cao7113
- Created: 2018-07-30T09:44:27.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-03-17T00:42:52.000Z (over 3 years ago)
- Last Synced: 2025-06-17T10:46:06.533Z (about 1 year ago)
- Topics: db, sql
- Language: Ruby
- Homepage:
- Size: 64.5 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Dba, our db tools, powered by ruby
## Features
* manage db config in one place
* use favored command tools eg. pgcli, psql, sequel
* connect as easy as possible
* write sqlets(db script) quickly
* make test and run easily
* try and learn advanced db knowledge
## Quick start
* config `~/.dbs.yml`(or `DBSFILE` env) as `sample-dbs.yml`
* install ruby locally eg. `brew install ruby`
* install pg locally eg. `brew install postgresql@9.6`
* run `bundle install`
* put `source /path/to/here/dba.rc` in your `~/.bashrc`
### Try
run like below:
```
dbcli help
dbmigrate help
pga help
rake demo
sql/demo.rb
rspec spec/try_db_spec.rb
```
## Run with docker
```
dockerdba down # get image
# config ~/.dbs.yml with a docker_test db item
dockerdba try
# write your scripts by dockerdba/try.sh
```
## Used in starup
### pull staging db to local
* `pga gen_datafile postgres://xxx/to_staging_db`
生成大表过滤规则文件(如`.datafiles/starup.pg.staging.localdomain.5432.yml`), 可自行编辑该规则文件
* `pga copy postgres://src_staging_db_url/db1 postgres://localhost/new_not_exist_db1 --dryrun`
生成shell脚本,去掉--dryrun可立即触发执行。可自行定制生产的shell脚本
## Inspired by
* https://github.com/Microsoft/pgtester
* https://medium.com/yammer-engineering/testing-postgresql-scripts-with-rspec-and-pg-tester-c3c6c1679aec