PostgreSQL Python
- Connecting to the PostgreSQL database server
- Creating new PostgreSQL tables in Python
- Inserting data into the PostgreSQL table in Python
- Updating data in the PostgreSQL table in Python
- Transaction
- Querying data from PostgreSQL tables
- Calling a PostgreSQL function in Python
- Calling a PostgreSQL stored procedure in Python
- Handling PostgreSQL BLOB data in Python
- Deleting data from PostgreSQL tables in Python
Log into the PostgreSQL database server using pgAdmin or psql and create a database in the database server
Update apt
sudo apt update
Install postgresql
sudo apt install postgresql postgresql-contrib
start the service
sudo systemctl start postgresql.service
set password for -user postgres
sudo -u postgres psql postgres
enter the following cmd and set password for postgres user
\password postgres
CREATE DATABASE mybusiness;
Create table
Construct STATEMENT
CREATE TABLE
Connect to the PostgreSQL database
Create a cursor
Execute the sql statements
Finally close the cursor and connection
Run the cmd on psql to enter into the database: mybusiness
\c mybusiness
mybusiness=# \dt