PythonPG8000 SQL,插入。。。不将信息写入制表符

2024-06-08 02:10:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我连接到一个SQL数据库(heroku),我可以在那里创建一个表。在

当插入一些信息时,我没有发现任何错误。 但当我想读取数据时,它返回“None”。 我做错什么了?在

import pg8000

conn = pg8000.connect(user="username", password="password", 
host="hostAddress", port=5432, database="database", 
ssl=True)
cursor = conn.cursor()

def createTable():
    cursor.execute("create table test (ID INT, TITLE TEXT)")
    conn.commit()

def dataEntry():
    cursor.execute("INSERT INTO test VALUES(1, 'blablabla')")
    conn.commit()

def readTable():
    print (cursor.execute("SELECT * FROM test "))

#createTable()
dataEntry()
readTable()

非常感谢你的帮助!在


Tags: test数据库executesqlherokudefpasswordconn

热门问题