- Install Psycopg2 package in Python
pip install psycopg2 or
pipenv install psycopg2 (virtual python environment)
- Install postgresql in Ubuntu
sudo apt update
sudo apt install postgresql postgresql-contrib
- After successfully install postgresql, the default role is postgres. So when you connect postgresql service in your own Ubuntu user, you cannot connect it, reporting the username not in the role. Thus create a role using your own username, and add your username in ROLE of postgres
psql postgres
postgres=# CREATE ROLE ubuntu_username superuser;
postgres=# ALTER ROLE ubuntu_username WITH LOGIN;
- In python, connect postgresql, e.g.
import psycopg2
conn = psycopg2.connect("dbname=test user=user_name")
-
Previous
Hornbill, too hot, hidden in tree, in west coast park -
Next
Sunset after raining on Sunday and today’s cloud dog
FEATURED TAGS
computer program
javascript
nvm
node.js
Pipenv
Python
美食
AI
artifical intelligence
Machine learning
data science
digital optimiser
user profile
Cooking
cycling
green railway
feature spot
景点
work
technology
F1
中秋节
dog
setting sun
sql
photograph
Alexandra canal
flowers
bee
greenway corridors
programming
C++
passion fruit
sentosa
Marina bay sands
pigeon
squirrel
Pandan reservoir
rain
otter
Christmas
orchard road
PostgreSQL
fintech
sunset
thean hou temple in sungai lembing
海上日出
SQL optimization
pieces of memory
回忆
garden festival
ta-lib
backtrader
chatGPT
stable diffusion webui
draw.io
streamlit
LLM
prompt engineering
fastapi
stock trading
artificial-intelligence