Guest User

Untitled

a guest
Nov 27th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import psycopg2
  2. import psycopg2.extensions
  3. import sys
  4.  
  5. def main():
  6. proyecto="host='localhost' dbname='api' user='postgres' password='123456789'"
  7. obj= psycopg2.connect(proyecto)
  8. cur=obj.cursor()
  9. cura= "SELECT * FROM public."pensum" WHERE "Id.Carrera" = %s "
  10. a= 1
  11. cur.execute(cura,[a])
  12. a2=cur.fetchone()
  13. print(a2)
  14.  
  15. main()
  16.  
  17. id.carrera | clase
  18. -----------------------------
  19. ( 1 ,'TRABAJO DE GRADO')
  20.  
  21. id.carrera | clase
  22. -----------------------------
  23. 1 ;"TRABAJO DE GRADO"
  24. 1 ;"CATEDRA UDECINA"
  25. 1 ;"CONSTITUCION Y DEMOCRACIA"
  26. 1 ;"DEPORTES"
  27.  
  28. cur.execute(cura,[a])
  29. for a2 in cur.fetchall()
  30. print(a2)
  31.  
  32. cur.execute(cura,[a])
  33. while True:
  34. rows = cur.fetchmany(5)
  35. if not rows:
  36. break
  37.  
  38. for row in rows:
  39. print(row)
  40.  
  41. cur.execute(cura,[a])
  42. a2 = cur.fetchone()
  43. while (a2 != None):
  44. print (a2)
  45. registro = cur.fetchone()
  46.  
  47. for a2 in cur.execute(cura,[a]):
  48. print (a2)
Add Comment
Please, Sign In to add comment