Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. import psycopg2
  2. conn = psycopg2.connect(user = "#######",
  3. password = "###########",
  4. host = "psql.wmi.amu.edu.pl",
  5. database ="##########")
  6.  
  7. cursor = conn.cursor()
  8.  
  9. myinput = input("Wprowadź nazwe tabeli: ")
  10. myallinput = 'SELECT * FROM '+myinput
  11.  
  12. cursor.execute(myallinput)
  13.  
  14. j=0
  15. column =""
  16. for i in cursor.description:
  17. column +=" "+ cursor.description[j][0] +" "
  18. j+=1
  19. print(column)
  20. print("")
  21. j=0
  22. x=""
  23. q=1
  24. for table in cursor.fetchall():
  25. for i in cursor.description:
  26. x +=str(table[j]) +" "
  27. j += 1
  28. print(str(q)+"|"+" "+x)
  29. x=""
  30. j=0
  31. q+=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement