Luigi Marongiu
2021-Nov-10 12:27 UTC
[R] how to connect libreoffice base odb using R package odbc?
how can I connect to a LibreOffice base odb file using the package odbc for R? I tried with:> library(odbc) > library(DBI) > con <- dbConnect(odbc::odbc(),+ driver = "PostgreSQL Driver", + database = "proof.odb", + uid = "", + pwd = "", + host = "localhost", + port = 5432) Error: nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Driver Manager]Can't open lib 'PostgreSQL Driver' : file not found> con <- dbConnect(odbc::odbc(),+ driver = "/usr/local/lib/psqlodbcw.so", + database = "proof.odb", + uid = "", + pwd = "", + host = "localhost", + port = 5432) Error: nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Driver Manager]Can't open lib '/usr/local/lib/psqlodbcw.so' : file not found> con <- dbConnect(odbc::odbc(),+ driver = "/usr/local/lib/libsqlite3odbc.dylib", + database = "proof.odb", + uid = "", + pwd = "", + host = "localhost", + port = 5432) Error: nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Driver Manager]Can't open lib '/usr/local/lib/libsqlite3odbc.dylib' : file not found ``` What would be the correct driver/syntax? -- Best regards, Luigi
Rasmus Liland
2021-Nov-10 14:43 UTC
[R] how to connect libreoffice base odb using R package odbc?
Dear Luigi, I found the package ODB https://cran.r-project.org/web/packages/ODB/ODB.pdf and was able to install it after reconfiguring rJava ... The help page ?ODB::odb.open has this example: odbFile <- tempfile(fileext=".odb") odb.create(odbFile, overwrite="do") odb <- odb.open(odbFile) # New table odb.write(odb, "CREATE TABLE fruits (name VARCHAR(6) PRIMARY KEY)") odb.insert(odb, "fruits", c("banana", "pear", "peach")) # Writes to the file and closes the connection odb.close(odb, write=TRUE) Best, Rasmus -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20211110/8bea907b/attachment.sig>