# Direct inserting a DataFrame into SQLite without using SQL?

**URL:** https://discourse.julialang.org/t/direct-inserting-a-dataframe-into-sqlite-without-using-sql/91103
**Category:** Data
**Created:** [December 1, 2022, 3:35pm UTC](https://discourse.julialang.org/t/direct-inserting-a-dataframe-into-sqlite-without-using-sql/91103 "2022-12-01T15:35:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![tomtom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomtom/32/5106_2.png) [@tomtom](https://discourse.julialang.org/u/tomtom)
#### Post date: [December 1, 2022, 3:35pm UTC](https://discourse.julialang.org/t/direct-inserting-a-dataframe-into-sqlite-without-using-sql/91103/1 "2022-12-01T15:35:52Z")

</div>

I wonder if there is any package that allows a `DataFrame` to be:

1. created as a SQLite table
2. inserted into an existing SQLite table  
withOUT using SQL???

something like:

1. `create(df, "fname.sqlite")`  
and
2. `insert(df, "fname.sqlite")`  
would be perfect! (`df` is a `DataFrame` and “fname.sqlite” is the file name of the SQLite table)

Thanks!

---

<div class="post-metadata">

### Author: ![p-gw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/p-gw/32/210518_2.png) [@p-gw](https://discourse.julialang.org/u/p-gw)
#### Post date: [December 1, 2022, 4:12pm UTC](https://discourse.julialang.org/t/direct-inserting-a-dataframe-into-sqlite-without-using-sql/91103/2 "2022-12-01T16:12:34Z")

</div>

Yes, this is possible:

```julia
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!](https://juliadatabases.org/SQLite.jl/stable/#SQLite.load!).
