Answer the question
In order to leave comments, you need to log in
Why does an error occur when running python3.6 with postgresql?
Good afternoon, I'm just starting to learn the work of postgresql and indeed sql. I know a little python.
I am using the postgresql.driver module. By the way, I have not yet understood why there are a lot of them PyGreSQL, psycopg2 and which one is better to use. If you tell me what is the difference, and which is better to use, I will be grateful.
I connect to the database like this:
import postgresql.driver as pg
db = pg.connect(user='xxxx', password='xxxx', host='localhost', database='english', port=5432)
for name in db.prepare("SELECT russian FROM english WHERE number = 1"):
print(name)
db.close()
print (db.prepare("SELECT russian FROM english WHERE number = 1"))
word = db.prepare("SELECT russian FROM english WHERE number = 1")
print (word)
Answer the question
In order to leave comments, you need to log in
It's not an error, it's a textual representation of a prepared query . In the first example, you loop through it, and in the second and third, you print it out.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question