You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

37 lines
909 B

import sqlalchemy
import pandas as pd
from config import pwd_postgres as pwd
from sqlalchemy import create_engine
from sqlalchemy.types import Integer
copy_table = 'people'
engine = sqlalchemy.create_engine(f"postgresql://pi:{pwd}@{'98.128.174.224'}:5432/riksdagen")
df = pd.read_sql(f"select * from {copy_table}", engine)
#df.drop(["index"], axis=1, inplace=True)
#df["text_lower"] = df["text"].apply(lambda x: x.lower())
#df.rename({"file": "id_session"}, inplace=True, axis=1)
print(len(df))
df = df.drop_duplicates()
engine = create_engine(
"postgresql://lasse:laconic-course-compote-fargo-remodel-porous@192.168.1.10:5432/riksdagen"
)
df.to_sql(
copy_table,
engine,
dtype={
"year": Integer(),
"number": Integer(),
"start": Integer(),
"duration": Integer(),
},
chunksize=10000,
method="multi",
if_exists="replace",
index=False,
)