No connection to sqlite database

con <- DBI::dbConnect(dbDriver("SQLite"),"db_projektarbeit.sqlite")
rs <- DBI::dbSendQuery(con, "select * from Material_Master")

and i get the error message:
Error in result_create(conn@ptr, statement) :
no such table: Material_Master

and the table looks like:
image

Did you try to specify the schema ?

rs <- DBI::dbSendQuery(con, "select * from Tabellen.Material_Master")

You may not be connected with the schema by default so it must be specified.

thank you but this didnt helped
image

ok, i started R studio again and now it works with the schema..

You can try a DBI::dbListTables() to see if the tables are seen by R.
As your table have an _ you may need to quote the SQL statement.

Usually I use dbplyr and dplyr to connect

library(DBI)
con <- dbConnect(RSQLite::SQLite(), ":memory:")
dbWriteTable(con, "mtcars", mtcars)
dbListTables(con)
#> [1] "mtcars"
library(dplyr, warn.conflicts = FALSE)
tab <- tbl(con, 'mtcars')
tab %>%
  select(cyl)
#> # Source:   lazy query [?? x 1]
#> # Database: sqlite 3.22.0 [:memory:]
#>      cyl
#>    <dbl>
#>  1     6
#>  2     6
#>  3     4
#>  4     6
#>  5     8
#>  6     6
#>  7     8
#>  8     4
#>  9     4
#> 10     6
#> # ... with more rows

Created on 2019-06-08 by the reprex package (v0.3.0.9000)

Using dbplyr::in_schema when a shema is required.

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.