关于dbt的配置和链接mysql测试

本地windows安装步骤:
1、安装python, 推荐python3.9, 也可以安装miniconda的版本(推荐直接安装miniconda:安装见:https://blog.csdn.net/weixin_43828245/article/details/124768518)
.
2、在miniconda的虚拟环境,直接 运行命令pip install dbt-core dbt-postgres
其中dbt-core是核心包, 必须安装, dbt-postgres是连接适配器, 演示使用postgres作为数据库, 可以根据实际的数据库类型选择其他种类的适配器, 例如:dbt-mysql;直接链接postgres数据库的见:https://zhuanlan.zhihu.com/p/560691123;

3、如果是需要链接mysql,需要安装python3.9版本;具体见官网:https://github.com/dbeatty10/dbt-mysql 支持的 Python 版本为:3.6、3.7、3.8 和 3.9

4、conda create -n py39 python=3.9 安装 3.9 版本 和conda activate py39 激活3.9版本

5、conda install -c conda-forge dbt-mysql mysql-connector-python 安装链接mysql的依赖包

6、https://docs.getdbt.com/docs/core/connect-data-platform/mysql-setup 官网测试mysql的

7、dbt init 初始化 按照提示输入项目名称, 输入fund_analysis, 再选择数据库类型postgres.

8、dbt debug –config-dir 初始化项目的路径

9、mysql的配置和postgresql配置不一样

  type: mysqldriver: mysqlconnector  threads: 1host: port: username: password:schema: 数据库名称
#dev:
#  type: postgres
#  threads: 1
#  host:
#  port: 
#  user:
#  pass: 
#  dbname: 
#  schema: 

本文链接:https://my.lmcjl.com/post/1371.html

展开阅读全文

4 评论

留下您的评论.