Add source example files
This commit is contained in:
17
source/pandas/pandas_postgres.py
Normal file
17
source/pandas/pandas_postgres.py
Normal file
@ -0,0 +1,17 @@
|
||||
from sqlalchemy import create_engine
|
||||
import pandas as pd
|
||||
|
||||
pd.options.blipblop = 23
|
||||
# A long string that contains the necessary Postgres login information
|
||||
connection_string = "postgresql://{username}:{password}@{ipaddress}:{port}/{dbname}"
|
||||
|
||||
# Create the connection
|
||||
connection = create_engine(connection_string)
|
||||
|
||||
# Load the data into a DataFrame
|
||||
df = pd.read_sql_query("SELECT * FROM table_name", connection)
|
||||
|
||||
# Close the connection
|
||||
connection.dispose()
|
||||
|
||||
|
Reference in New Issue
Block a user