用于同步heroku、本地和远程服务器上的并行postgresql数据库的实用程序
paragres的Python项目详细描述
同步heroku上并行postgresql数据库的实用程序, 本地和远程服务器
喜欢我的工作?给我小费!https://www.paypal.me/jessamynsmith
功能
在不同地点之间轻松复制数据库,例如:
- 用本地数据初始化Heroku数据库
- 使用Heroku应用程序中的最新数据更新本地开发数据库
- 使用来自另一个应用程序(如生产)的数据更新一个Heroku应用程序(如暂存)
安装
您可以使用以下命令从PYPI获得优秀选手:
pip install paragres
开发版本可以安装:
pip install -e git://github.com/jessamynsmith/paragres.git#egg=paragres
如果您是在本地开发,则可以从 工作目录:
python setup.py.install
用法
注1:要使用Paragres访问Heroku应用程序,您必须登录到Heroku帐户 拥有那个应用程序。
注意2:默认情况下,使用heroku的新pg:backups命令。如果要使用旧的pgbackups 加载项,必须指定–使用pgbackups
示例1,在Heroku数据库之间复制数据:
paragres -s <source_heroku_app_name> -d <destination_heroku_app_name>
示例2,从Heroku数据库复制数据的新备份快照 到本地主机:
paragres -s <heroku_app_name> -c -t path/to/db_settings.py
示例3,创建Heroku数据库的备份快照:
paragres -c -s <heroku_app_name>
db_settings.py必须至少包含以下内容(django设置 文件格式:
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': '<db_name>', 'USER': '<username>', 'PASSWORD': '<password>', 'HOST': '<host>', 'PORT': '<port>', } }
支持的传输:
Destination | |||
---|---|---|---|
postgres | Heroku app | ||
Source | local file | X | |
postgres | X | X * | |
url | X | X | |
Heroku app | X | X |
*只能从本地用户可访问的数据库推送,或 通过PG*环境变量配置的用户可以访问
可选参数的完整列表:
-h, --help show this help message and exit --version Show program's version number -f FILE, --file FILE PostgreSQL dump file to use as a data source -u URL, --url URL Public URL from which to pull db file -s SOURCE_APP, --source-app SOURCE_APP Heroku app from which to pull db -c, --capture Capture a new Heroku backup -o SOURCE_SETTINGS, --source-settings SOURCE_SETTINGS Django-style settings file with database connection information for source database (or 'DJANGO_SETTINGS_MODULE' to use that environment variable's value) -b SOURCE_DBNAME, --source-dbname SOURCE_DBNAME Source database name (overrides value in source settings if both are specified) -d DESTINATION_APP, --destination-app DESTINATION_APP Heroku app for which to replace db -t SETTINGS, --settings SETTINGS Django-style settings file with database connection information for destination database (or 'DJANGO_SETTINGS_MODULE' to use that environment variable's value) -n DBNAME, --dbname DBNAME Destination database name (overrides value in settings if both are specified) -v VERBOSITY, --verbosity VERBOSITY Verbosity level: 0=minimal output, 1=normal output --use-pgbackups Use the deprecated pgbackups addon rather than Heroku pg:backups
开发
在github上派生项目,git克隆您的fork,例如:
git clone https://github.com/<username>/paragres.git
创建一个virtualenv并安装依赖项:
mkvirtualenv paragres pip install -r requirements/package.txt -r requirements/test.txt
运行覆盖率为100%的测试并检查代码样式:
coverage run -m nose coverage report -m flake8
验证所有受支持的python版本:
pip install tox tox
安装本地副本:
python setup.py install