在AWS Lambda中使用psycopg2连接Redshift

本文介绍了如何在AWS Lambda中使用psycopg2连接Redshift。由于Lambda运行环境的特殊性,直接安装psycopg2会遇到错误。通过在Linux环境中编译特定版本的库,可以解决这一问题,实现Lambda与Redshift的顺利连接。
摘要由CSDN通过智能技术生成
  • 环境:MacOS 10.12.6

开始说正题。

Redshift是基于PostgreSQL的二次开发应用,所以,能连接PostgreSQL的工具都可以用来连接Redshift。我选择的是使用最广泛的psycopg2

如果上来就执行:

$ pip install psycopg2

你会看到下面的提示错误:

Error: pg_config executable not found.
    
    pg_config is required to build psycopg2 from source.  Please add the directory
    containing pg_config to the $PATH or specify the full executable path with the
    option:
    
        python setup.py build_ext --pg-config /path/to/pg_config build ...
    
    or with the pg_config option in 'setup.cfg'.
    
    If you prefer to avoid building psycopg2 from source, please 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值