#!/usr/bin/python
import psycopg2
import sys
import psycopg2.extras
def main():
#from config import config
conn=psycopg2.connect(host="localhost",user="postgres",database="firstdb");
cur=conn.cursor('cursor_unique_name', cursor_factory=psycopg2.extras.DictCursor)
cur.execute("select * from data")
row_count = 0
for row in cur:
row_count += 1
#print "abc"
print "row: %s %s\n" % (row_count, row)
print "hello";
print "Hello there I am working Man!!!...";
if __name__ == "__main__":
main()
このスクリプトで行を印刷できないため、このスクリプトのエラーを修正できますか?シェル上でのPythonとPostgresの接続
最後の印刷が1回実行されます。python firstname.py
です。
私はpg_hba.conf
に変更を加えましたが、他の回答では示唆されていますが、まだ成功していません。
自分自身ではありませんが、 'for row in cur'を' for row in cur.fetchall() 'に置き換えようとしましたか? –
はい!私はそうしましたが、それもまったく働かなかった –
私はそれを感謝しました! –