A
A
AlerX2019-05-22 17:35:48
Python
AlerX, 2019-05-22 17:35:48

Postgresql throws an error on execute query, what's the problem?

Good afternoon, I want to display a list of all users from a Postgresql table
Output code:

sql.execute('SELECT count(user_id) FROM main')
users = sql.fetchall()

The problem is that Postgresql gives an error
psycopg2.ProgrammingError: no results to fetch
Sometimes it happens that postgresql gives the number of users correctly.
What is the reason for this? And how to solve it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question