1 Star 0 Fork 1

OliverChris/Udacity-Data-Engineering-Projects

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Redshift_test.py 650 Bytes
一键复制 编辑 原始数据 按行查看 历史
san089 提交于 2020-03-04 23:51 . Adding new project
import psycopg2
import configparser
# Loading cluster configurations from cluster.config
config = configparser.ConfigParser()
config.read_file(open('cluster.config'))
def test_connection(host):
dbname = config.get('DWH','DWH_DB')
port = config.get('DWH','DWH_PORT')
user = config.get('DWH','DWH_DB_USER')
password = config.get('DWH','DWH_DB_PASSWORD')
con=psycopg2.connect(dbname= dbname, host=host, port= port, user= user, password= password)
cur = con.cursor()
cur.execute("CREATE TABLE test (id int);")
cur.execute("INSERT INTO test VALUES (10);")
print(cur.execute('SELECT * FROM test'))
con.close()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/oliverchris789/Udacity-Data-Engineering-Projects.git
git@gitee.com:oliverchris789/Udacity-Data-Engineering-Projects.git
oliverchris789
Udacity-Data-Engineering-Projects
Udacity-Data-Engineering-Projects
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385