good day I'm working on a project where I need to consult different databases and for that I use the psycopg2 extension of python, however at the time of making a query it only shows me the first data of it , despite the fact that there is a lot of repeated data
import psycopg2
import psycopg2.extensions
import sys
def main():
proyecto="host='localhost' dbname='api' user='postgres' password='123456789'"
obj= psycopg2.connect(proyecto)
cur=obj.cursor()
cura= "SELECT * FROM public.\"pensum\" WHERE \"Id.Carrera\" = %s "
a= 1
cur.execute(cura,[a])
a2=cur.fetchone()
print(a2)
main()
which only results in me
id.carrera | clase
-----------------------------
( 1 ,'TRABAJO DE GRADO')
However, when doing the SQL query, all the results are bounced:
id.carrera | clase
-----------------------------
1 ;"TRABAJO DE GRADO"
1 ;"CATEDRA UDECINA"
1 ;"CONSTITUCION Y DEMOCRACIA"
1 ;"DEPORTES"
I would like to know why with python only one result is thrown and how to make me show all the data I need. thanks