Skip to content

Instantly share code, notes, and snippets.

@vnegi10
Last active July 15, 2023 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vnegi10/3559e59648d3cf9094dca1a4b931b73e to your computer and use it in GitHub Desktop.
Save vnegi10/3559e59648d3cf9094dca1a4b931b73e to your computer and use it in GitHub Desktop.
function add_to_fruit_table(conn_master,
db_name::String,
table_name::String,
df_input::DataFrame)
conn = create_fruit_table(conn_master, db_name, table_name)
stmt = try
DBInterface.prepare(conn,
"INSERT INTO $(table_name) VALUES(?, ?, ?)")
catch
error("Unable to prepare statement")
end
try
DBInterface.executemany(stmt,
(df_input[!, 1],
df_input[!, 2],
df_input[!, 3],
)
)
catch
error("Unable to execute multiple statements")
finally
DBInterface.close!(stmt)
DBInterface.close!(conn)
end
return nothing
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment