1
AWS redshift에 postgres 데이터베이스가 있습니다. 현재 파이썬 Pyscopg2를 사용하여 데이터베이스와 상호 작용합니다. 내가 실행할 수있는 것을 발견 :python pyscopg2가 AWS redshift에서 데이터를 선택할 수 없습니다.
curosr.execute("INSERT INTO datatype VALUES (%s, %s)", ("humidity", "some description"))
connect.commit()
을하지만, 내가 할 때 내가 무엇을 적
for row in cursor.execute("SELECT * FROM datatype"):
print(row)
은 항상 나에게 없음 형태를 돌려줍니다. 누구나 내가 레드 쉬프트 포스트 그레스와 상호 작용하는 올바른 방법은 무엇인지 조언 해 줄 수 있습니까? 당신이 그것을 필요는 없지만, 선택시 -
는 이 업데이트 할 때, "fetchall()은"여기 전체 코드
##encoding=utf8
from __future__ import print_function
import psycopg2
def connect():
conn = psycopg2.connect(host = "wbh1.cqdmrqjbi4nz.us-east-1.redshift.amazonaws.com",
port = 5439,
dbname = "dbname",
user = "user",
password = "password")
c = conn.cursor()
return conn, c
conn, c = connect()
c.execute("INSERT INTO table netatmo VALUES (%s, %s)", (1, 10.5))
conn.commit() # this works, and I can see the data in other db client software
for row in c.execute("SELECT * FROM netatmo").fetchall(): # this not working
print(row) # AttributeError: 'NoneType' object has no attribute 'fetchall'
아니 그 이유가 아니야, 나는 fechall fechone을 시도, curosr는 항상 Null을 반환합니다, 심지어 SQL cmd는 다른 데이터베이스 클라이언트 소프트웨어에 많은 레코드를 제공합니다 – MacSanhe
전체 코드를 붙여 넣을 수 있습니까? – alexanderlz
고맙습니다. 제 질문을 편집합니다. – MacSanhe