tomtom
1
I wonder if there is any package that allows a DataFrame
to be:
- created as a SQLite table
- inserted into an existing SQLite table
withOUT using SQL???
something like:
-
create(df, "fname.sqlite")
and
-
insert(df, "fname.sqlite")
would be perfect! (df
is a DataFrame
and “fname.sqlite” is the file name of the SQLite table)
Thanks!
p-gw
2
Yes, this is possible:
using DataFrames, SQLite
df = DataFrame(a = 1:10, b = rand(10))
db = SQLite.DB(":memory:")
df |> SQLite.load!(db, "mytable")
# check entries
DataFrame(DBInterface.execute(db, "select * from mytable;"))
# another load
df |> SQLite.load!(db, "mytable")
# check again
DataFrame(DBInterface.execute(db, "select * from mytable;"))
Instead of ":memory:"
you can specify your database file.
For more information you can take a look at the SQLite.load!
documentation.
https://juliadatabases.org/SQLite.jl/stable/#SQLite.load!.
5 Likes