PostgreSQL Python: Querying Data

preview_player
Показать описание
The steps for querying data from PostgreSQL table
1. Create a new database connection to the PostgreSQL database server.
2. Create a new cursor.
3. Execute the SELECT statement with the input values.
4. Using the fetchone(), fetchall() or fetchmany() method.
5. Call the close() method of the cursor and connection objects to close the connection

How about the fetchone(), fetchall(), fetchmany() method?
👉 The fetchone() fetches the next row in the result set. It returns a single tuple or None when no more row is available.
👉 The fetchall() fetches all rows in the result set and returns a list of tuples. If there are no rows to fetch, the fetchall() method returns an empty list.
Рекомендации по теме
visit shbcf.ru