亚马逊红移的视图管理
room_with_a_view的Python项目详细描述
有视野的房间
亚马逊红移的视图管理
- 免费软件:apache软件许可证2.0
- 文档:https://room-with-a-view.readthedocs.io。
功能
room with a view是一个python脚本,它自动解析 用于查找视图和函数定义及其依赖项的SQL文件。那么 使这些视图与红移、自动删除和 根据需要重新创建依赖视图,以便没有错误。钥匙 好处是:
- 没有编写代码将视图sql发送到redshift:脚本会为您执行此操作。
- 编辑任何视图并同步它,而不必担心需要删除或重新创建 依赖于它的观点。
- 错误处理可以准确地告诉您视图中存在错误的位置。
- 脚本在原子事务中运行,因此不能意外地输入 通过同步某些视图而不是其他视图来破坏状态。
设置
- 安装程序包:pip install room_with_a_view。
- 创建settings.yaml,然后编辑该文件以配置redshift连接和.sql文件的位置。示例settings.yaml文件:
connections:default:host:localhostport:5432user:awsuserpassword:**CHANGEME**dbname:postgresdirectories:-.
- 你准备好了!尝试room_with_a_view sync-all同步所有视图,或room_with_a_view --help了解有关该命令的更多信息。
使用量
usage: room_with_a_view.py [-h] [--view-names [VIEW-OR-FUNCTION-NAME [VIEW-OR-FUNCTION-NAME ...]]] [--file-names [FILE-PATH [FILE-PATH ...]]] [--connection CONNECTION] [--settings SETTINGS] [--verbosity VERBOSITY] {sync,drop-all,sync-all,list,drop} Manages Redshift SQL views. Possible actions: sync: Syncs specific views or functions (identified by the --view-names or --file-names parameters). drop-all: Drops all views and functions in all .sql files in a set of directories (identified by the --directories parameter). The directory will be searched recursively. sync-all: Syncs all views and functions in all .sql files in a set of directories (identified by the --directories parameter). The directory will be searched recursively. list: lists all known views and functions. drop: Drops specific views or functions (identified by the --view-names or --file-names parameters). positional arguments: {sync,drop-all,sync-all,list,drop} The action to perform. optional arguments: -h, --help show this help message and exit --view-names [VIEW-OR-FUNCTION-NAME [VIEW-OR-FUNCTION-NAME ...]] Names of views or functions to which to apply the action. --file-names [FILE-PATH [FILE-PATH ...]] Paths to .sql files to which to apply the action. --connection CONNECTION Name of the Redshift connection to use (or "default", if not specified). The name must match a connection in settings.yaml --settings SETTINGS Location of the settings file (settings.yaml by default) --verbosity VERBOSITY Verbosity of script output. 0 will output nothing, 1 will output names of views and functions being dropped and created, and 2 will output all executed sql
示例
- room_with_a_view.py sync-all:同步settings.yaml中指定的默认目录中所有sql文件中的所有视图和函数。删除并重新创建现有视图,并确保按依赖顺序创建视图。
- room_with_a_view.py sync --view-names my_view1 my_func1 --file-names../sql/my_file.sql:同步特定视图my_view1和函数my_func1,以及文件../sql/my_file.sql中的所有视图和函数。
- room_with_a_view.py drop-all--connection other_connection:删除默认目录中的所有视图和函数,使用名称other_connection下的settings.yaml中指定的连接信息连接到redshift。
- room_with_a_view.py drop --view-names my_view1 --directories other_dir1 other_dir2 --settings /path/to/fancy_settings.yaml:删除视图my_view1,在位于/path/to/fancy_settings.yaml的设置文件中的other_dir1和other_dir2指定的目录中查找包含该视图及其依赖项的SQL文件。
学分
这个包是用Cookiecutter和audreyr/cookiecutter-pypackage项目模板创建的。
历史记录
0.1.0(2018-05-28)
- pypi上的第一个版本。