Skip to content

Connect PostgreSQL database from Python, using the psycopg2 or SQLAlchemy library. The most common and reliable library for interacting with PostgreSQL databases and Python

Notifications You must be signed in to change notification settings

sirmilltech/Connecting-POSTGRES-SQL--from-python

Repository files navigation

Connecting-POSTGRES-SQL--from-python

Connect PostgreSQL database from Python, using the psycopg2 or SQLAlchemy library. The most common and reliable library for interacting with PostgreSQL databases and Python

Explanation:

create_engine(): Establishes a connection to the PostgreSQL database using the connection string.
Connection string format: "postgresql+psycopg2://user:password@host:port/database"
connection.execute(): Executes an SQL query.
result.fetchall(): Fetches all rows from the query result.
pandas.DataFrame(): Converts the result into a DataFrame for easier viewing and manipulation (optional).

About

Connect PostgreSQL database from Python, using the psycopg2 or SQLAlchemy library. The most common and reliable library for interacting with PostgreSQL databases and Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published