Guest User

Untitled

a guest
Jan 22nd, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #!/usr/bin/python
  2. import psycopg2
  3.  
  4. connection = psycopg2.connect(
  5. database="postgres",
  6. user = "postgres",
  7. password = "12345678",
  8. host = "127.0.0.1",
  9. port = "5432")
  10. print("Opened database Esquilo successfully")
  11. cursor = connection.cursor()
  12. cursor.execute('''SELECT * FROM person ORDER BY id ASC''')
  13. record = cursor.fetchall()
  14. for row in record:
  15. print('ID', row[0])
  16. print('NAME', row[1])
  17. print('AGE', row[2])
  18. print('ADDRESS', row[3])
  19. print('SALARY', row[4], '\n')
  20. print("Query success!!!")
  21. connection.commit()
  22. connection.close()
Add Comment
Please, Sign In to add comment