Skip to content

Instantly share code, notes, and snippets.

@johnmastro
Created March 22, 2021 21:04
Show Gist options
  • Save johnmastro/503c7b3356161fadcc5dae6a1805a895 to your computer and use it in GitHub Desktop.
Save johnmastro/503c7b3356161fadcc5dae6a1805a895 to your computer and use it in GitHub Desktop.
# Make sure the table is created in the db even if it's empty. This is ugly,
# including in that every column will have type `string`, but the types will be
# fixed up as soon as there's actual data to load
if count == 0:
nulls_df = result_to_df([], field_info)
nulls_df = pd.concat(
[nulls_df, pd.DataFrame([{c: None for c in nulls_df.columns}])]
)
nulls_df.to_sql(
# ...
)
connection.execute(f"delete from identifier('{schema}.{temporary_table}') ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment