用于连接Postgres/Greenplum、MySQL、MongoDB、Kafka、Redis、MixPanel和Salesforce的Python包装器。还包括用于执行安全文件传输和查找环境变量的模块。
dattasa的Python项目详细描述
帮助数据工程师和数据科学家加速数据管道开发的python包
这个python项目的目标是构建一堆可以 可用于从关系数据库中生成数据管道: Postgres、MySQL、Greenplum、Redshift等-NoSQL数据库:Hive, 消息源和缓存:kafka、redis、rabbitmq等。 -云服务提供商:Salesforce、MixPanel、Jira、Google Drive, 很高兴,低音等等。
安装
有三种方法可以安装Dattasa软件包-
- 最简单的方法是使用pip从pypi安装
pip install dattasa
- 从github下载并从头开始构建
git clone git@github.com:kartikra/dattasa.git cd dattasa python setup.py build python setup.py clean python setup.py install
- 从github下载并使用pip安装
git clone git@github.com:kartikra/dattasa.git cd dattasa pip install -e . pip install -U -e . (if upgrading)
配置文件
默认情况下,dattasa希望配置文件位于mode目录中 用户的。这些可以被覆盖。请参阅自述文件中示例代码的链接 请在下面的文件中查找更多信息。有两个yaml配置文件- database.yaml-所需的数据库凭据和api密钥的圆锥图 建立联系。请参见sample database config-ftpsites.yaml-needed for 执行SFTP传输。见sample ftpsites config
环境变量
dattasa包依赖于以下环境变量。确保 在bash profile-gpload_home:path to gpload包中设置这些 (仅当对Greenplum或Redshift使用gpload实用程序时才需要)- project_home:指向python项目目录的路径- project_home/python_bash_脚本:调用gpload的python脚本 (仅当对Greenplum或Redshift使用gpload实用程序时才需要)- SQL目录:保存所有SQL脚本的位置-temp目录:所有临时文件 在此文件夹中创建-日志目录:所有日志文件都在 文件夹
类别说明
包的v1.0包含以下类。请看链接 以获取有关如何使用它们的详细信息的示例代码。
class | Description | Sample Code |
---|---|---|
environment | Lets you source all the os environment variables | see first row in mongo example |
postgres_clien t | Lets you use psql and gpload utilities provided by pivotal greenplum. Make connections to postgres / greenplum database using pyscopg2 or sqlalchemy.Use the connections to interact with database in interactive program or run queries from a sql file using the connection | sample postgres code |
greenplum_clie nt (inherits postgres_clien t) | Lets you use psql and gpload utilities provided by pivotal greenplum. Make connections to postgres / greenplum database using pyscopg2 or sqlalchemy.Use the connections to interact with database in interactive program or run queries from a sql file using the connection | sample greenplum code |
mysql_client | Lets you use mysql and other methods provided by PyMySQL Package | sample mysql code |
file_processor | Create sftp connection using paramiko package. Other file manipulations like row_count, encryption, archive (File Class) | see file processing example |
notification | Send email notifications | |
mongo_client | Load data to mongodb using bulk load. Run java script queries | see mongo example |
redis_client | Read data from a redis cache or load a redis cache | see redis example |
kafka_system | Currently allows Publisher and Consumer to use kafka in batch mode | see kafka example |
rabbitmq_syste m | Currently has Publisher to publish messages in rabbitmq | |
mixpanel_clien t | Connect to mixpanel api and fetch data using jql or export raw events data. mixpanel api documentation | see mixpnael section in api example |
salesforce_cli ent | Create a connection to salesforce using simple_salesforce package | see salesforce section in api example |
delighted_clie nt | Get nps scores and survey responses from delighted.api documentation | see delighted section in api example |
wootric_client | Gets nps scores and survey responses from wootric.api documentation | see wootric section in api example |
dag_controller | Functions needed to integrate this package within an airflow dag. airflow documentation and github project |
数据管道类
这是其他项目可以访问的主类。数据 管道由来自组件和api的数据组成。每个对象 数据处理器可以使用单独的数据流并对其进行处理 数据管道根据数据库类型决定调用哪些模块 (在配置文件中定义)。数据管道由3类组成- datacomponent:每个数据库连接都被认为是 数据组件对象。参见Postgres、MySQL、Greenplum等示例 api call之上:每个api调用都是一个apicall对象。参见示例 MixPanel,高兴,Salesforce和Wootric以上-数据处理器: 在数据组件之间传输和加载数据。see examples
将ipython笔记本文件添加到github
使用Git LFS请参见 documentation
- 如果使用Mac,请使用Brew安装Git LFS^{TT1}$
- 安装lfsgit lfs install
- 跟踪项目中的ipynb文件。转到项目文件夹并执行 git lfs track "*.psd"
- 将.*ipynb_checkpoints/添加到.gitignore文件
- 最后添加.gittattributes文件git add .gitatttributes
在pypi中部署代码
- 生成代码: python setup.py build && python setup.py clean && python setup.py install
- 推到pypitest:python setup.py sdist upload -r pypitest
- 推到pypi prod:python setup.py sdist upload -r pypi