# Writing data to Dremio via R

**URL:** <https://community.dremio.com/t/writing-data-to-dremio-via-r/10685>\
**Category:** Dremio University\
**Created:** [June 2, 2023, 10:16am UTC](https://community.dremio.com/t/writing-data-to-dremio-via-r/10685 "2023-06-02T10:16:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Someone894](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/someone894/32/4949_2.png) [@Someone894](https://community.dremio.com/u/Someone894)\
**Post date:** [June 2, 2023, 10:16am UTC](https://community.dremio.com/t/writing-data-to-dremio-via-r/10685/1 "2023-06-02T10:16:10Z")

</div>

Hello,

after I [manged](https://community.dremio.com/t/dremio-r-connection-without-encryption/10645) to connect to Dremio via R I came to the conclusion that i dislike the `RODBC` packe and read [here](https://community.dremio.com/t/getting-dremio-server-connected-to-r-dbplyr-dplyr-on-macos-using-odbc-driver/426/5) and there (https:/ /cojamalo.github.io/macOS\_Dremio\_R/guide.html) to get it working with the `odbc` package, which is nicer.

So fa so good, i managed to read (`select * from . . .`) and write (`INSERT INTO . . . VALUES (21);`), but i cant write my own data.frame in a prepared statement.  
Here is an MWE with changed DB name:

```r
dremio_host <- "<Host>"
dremio_port <- "32010"
dremio_uid <- "<User>"
dremio_pwd <- "<Password>"

data <- data.frame(
  a = "AA",
  b = as.Date("01.02.2020", format = "%d.%m.%Y"),
  c = 500.1,
)

db.connection <- DBI::dbConnect(odbc::odbc(),
                                driver = "Arrow Flight SQL ODBC Driver",
                                uid = dremio_uid,
                                pwd = dremio_pwd,
                                host = dremio_host,
                                port = dremio_port,
                                AuthenticationType = "Basic Authentication",
                                ConnectionType = "Direct"
)

# CREATE TABLE "name" (
# a varchar(20),
# b DATE,
# c DOUBLE,
# );

db.query <- 'INSERT INTO "name"
  (a, b, c, d) VALUES
  (?, TO_DATE(?, \'YYYY-MM-DD\'), ?);'

result <- odbc::dbGetQuery(
  conn = db.connection,
  statement = db.query,
  params = data
)

result <- odbc::dbDisconnect(conn = db.connection)

```

which leads to an Error:  
` Error: nanodbc/nanodbc.cpp:1509: HY000: [Apache Arrow][Dremio Server] (100) Flight returned invalid argument error, with message: Illegal use of dynamic parameter`

Can you provide an example as to how i can write my R data.frame via the `odbc`-package in Dremio?

---

<div class="post-metadata">

**Author:** ![nachti](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/nachti/32/5005_2.png) [@nachti](https://community.dremio.com/u/nachti)\
**Post date:** [June 27, 2023, 1:39pm UTC](https://community.dremio.com/t/writing-data-to-dremio-via-r/10685/2 "2023-06-27T13:39:07Z")

</div>

I get a similar error message using the JDBC driver:

```auto
  Unable to create JDBC prepared statement
  JDBC ERROR: while preparing SQL: INSERT INTO dremio.mtcars VALUES(?,?,?,?,?,?,?,?,?,?,?)

```

---

<div class="post-metadata">

**Author:** ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)\
**Post date:** [June 27, 2023, 6:09pm UTC](https://community.dremio.com/t/writing-data-to-dremio-via-r/10685/3 "2023-06-27T18:09:22Z")

</div>

@Someone894 @nachti Looks like this needs support for parameterized prepare statement which is currently not yet supported, currently in the roadmap but no ETA

---

<div class="post-metadata">

**Author:** ![guray.uzun](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@guray.uzun](https://community.dremio.com/u/guray.uzun)\
**Post date:** [May 1, 2024, 1:40pm UTC](https://community.dremio.com/t/writing-data-to-dremio-via-r/10685/4 "2024-05-01T13:40:47Z")

</div>

I have tried to achieve the same using both with Arrow ODBC and JDBC drivers but ending up with same error message which is “Illegal use of dynamic parameter”.

Is this feature still not supported or is in the roadmap?

---

<div class="post-metadata">

**Author:** ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)\
**Post date:** [May 3, 2024, 9:07pm UTC](https://community.dremio.com/t/writing-data-to-dremio-via-r/10685/5 "2024-05-03T21:07:41Z")

</div>

@guray.uzun Will check on the status of the feature request and get back to you

---

<div class="post-metadata">

**Author:** ![isabella.gagner](https://avatars.discourse-cdn.com/v4/letter/i/22d042/32.png) [@isabella.gagner](https://community.dremio.com/u/isabella.gagner)\
**Post date:** [September 18, 2024, 9:20am UTC](https://community.dremio.com/t/writing-data-to-dremio-via-r/10685/6 "2024-09-18T09:20:55Z")

</div>

Any updates on this?

---

<div class="post-metadata">

**Author:** ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)\
**Post date:** [September 19, 2024, 4:53am UTC](https://community.dremio.com/t/writing-data-to-dremio-via-r/10685/7 "2024-09-19T04:53:23Z")

</div>

@isabella.gagner It is in the near roadmap but no ETA at this moment
