Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- conn_string = f'postgresql+psycopg2://{name}:{pas}@{host}/{database}'
- db = create_engine(conn_string, connect_args={'options': '-csearch_path={}'.format(schema)})
- conn = db.connect()
- dtypes = {
- '_id': sqlalchemy.types.BIGINT(),
- 'agency': sqlalchemy.types.TEXT(),
- '_ro_type': sqlalchemy.types.TEXT(),
- '_name': sqlalchemy.types.TEXT(),
- 'identifier': sqlalchemy.types.TEXT(),
- 'identifier_type': sqlalchemy.types.TEXT(),
- 'additional_identifier': sqlalchemy.types.TEXT(),
- 'additional_identifier_type': sqlalchemy.types.TEXT(),
- '_date': sqlalchemy.types.DATE(),
- 'rating': sqlalchemy.types.TEXT(),
- 'status': sqlalchemy.types.TEXT(),
- 'additional_industry': sqlalchemy.types.TEXT(),
- 'company_link': sqlalchemy.types.TEXT(),
- 'forecast': sqlalchemy.types.TEXT(),
- 'press_release_text': sqlalchemy.types.TEXT(),
- 'press_release_link': sqlalchemy.types.TEXT(),
- '_comment': sqlalchemy.types.TEXT(),
- 'scale': sqlalchemy.types.TEXT(),
- 'ogrn': sqlalchemy.types.TEXT(),
- 'fin_instrument': sqlalchemy.types.BOOLEAN(),
- 'uuid_from_level_1': sqlalchemy.types.UUID(),
- 'id_uuid': sqlalchemy.types.UUID(),
- 'json_additional': sqlalchemy.types.JSON()
- }
- if data_load is not None:
- if st.sidebar.button('Upload'):
- data = pd.read_excel(data_load)
- data = correct_data(data)
- for col in data.columns:
- if col not in dtypes.keys():
- data = data.drop(columns=[col])
- data.to_sql(f"{table}", con=conn, index=False, if_exists='replace',dtype=dtypes)
- st.write(f'Success inserting {len(data)} rows')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement