Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import psycopg2
- connection = psycopg2.connect(
- database="postgres",
- user = "postgres",
- password = "12345678",
- host = "127.0.0.1",
- port = "5432")
- print("Opened database Esquilo successfully")
- cursor = connection.cursor()
- cursor.execute('''SELECT * FROM person ORDER BY id ASC''')
- record = cursor.fetchall()
- for row in record:
- print('ID', row[0])
- print('NAME', row[1])
- print('AGE', row[2])
- print('ADDRESS', row[3])
- print('SALARY', row[4], '\n')
- print("Query success!!!")
- connection.commit()
- connection.close()
Add Comment
Please, Sign In to add comment