psycopg2
내 로컬 컴퓨터에서 실행중인 postgresql 데이터베이스를 사용해도 시도 할 때 결과를 반환 할 수 없습니다. 그것은 데이터베이스에 연결하는 것 같다. 왜냐하면 내가 config 매개 변수 중 하나를 변경하면 오류가 발생하지만, 겉으로보기에는 유효하고 결과가 좋은 쿼리를 실행할 때 아무것도 얻지 못하기 때문이다. 내 DB를 확실히 실행하고psycopg2가 결과를 반환하지 않습니다.
그 안에 테이블이 있습니다
postgres=# \c
You are now connected to database "postgres" as user "postgres".
postgres=# select * from foos;
name | age
---------+-----
Sarah | 23
Michael | 35
Alice | 12
James | 20
John | 52
(5 rows)
내 파이썬 코드는이 데이터베이스에 연결하지만, 아무리 내가 실행 어떤 쿼리, 내가 None
를 얻을 :
Python 2.7.3 (default, Apr 10 2013, 06:20:15)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> conn = psycopg2.connect("dbname='postgres' user='postgres' host='localhost'")
>>> cur = conn.cursor()
>>> print cur.execute("select * from foos;")
None
>>> print cur.execute("select * from foos")
None
>>> print cur.execute("select name from foos")
None
>>> print cur.execute("select f.name from foos f")
None
오전 나는 분명히 잘못된 것을하고있는 중입니까? 이 디버깅을 시작하려면 어떻게해야할까요? 연결이 잘된 이후로 어디에서 시작해야할지 모르겠습니다.
http://www.python.org/dev/peps/pep-0249/ – Ryan