[R] how to read a database in R?
John Kane
jrkr|de@u @end|ng |rom gm@||@com
Sat Feb 1 17:33:56 CET 2020
What happens if you run "dbListTables(db) "?
That is a warning not an error.
I am a real novice with data bases so I may not be of much help but do you
know where the db file came from?
When I suggested the code above. i checked that ii worked on a sqlite file
I had, and hoped that Ivan's miraculous inspiration was correct. It could
possibly be some other db type
I will attach my sample db here and if it makes it through, you should be
able to load it if RSQLite is functioning on your machine.
On Sat, 1 Feb 2020 at 10:10, Ana Marija <sokovic.anamarija using gmail.com> wrote:
> Hi John,
>
> I tried it but this is what I got:
>
> > library(RSQLite)
> > filename <- "DGN-WB_0.5.db"
> > sqlite.driver <- dbDriver("SQLite")
> > db <- dbConnect(sqlite.driver,
> + dbname = filename)
> Warning message:
> Couldn't set synchronous mode: disk I/O error
> Use `synchronous` = NULL to turn off this warning.
>
> Please advise,
> Ana
>
> On Sat, Feb 1, 2020 at 8:55 AM John Kane <jrkrideau using gmail.com> wrote:
> >
> > Hi Ana
> > Stolen from https://gist.github.com/jwolfson/72bc7d7fd8d339955b38
> > I cannot remember if you will need to install any other packages besides
> RSQLite
> >
> > library(RSQLite)
> > filename <- "your_db_file.db"
> > sqlite.driver <- dbDriver("SQLite")
> > db <- dbConnect(sqlite.driver,
> > dbname = filename)
> >
> > ## Some operations
> > dbListTables(db)
> > mytable <- dbReadTable(db,"your_table_name"
> >
> > Best of luck
> >
> >
> > On Sat, 1 Feb 2020 at 07:53, Ana Marija <sokovic.anamarija using gmail.com>
> wrote:
> >>
> >> Hi Ivan
> >>
> >> Thanks for getting back to me. Can you please share with me some code I
> >> would use to see what is in my database?
> >>
> >> On Sat, 1 Feb 2020 at 06:19, Ivan Krylov <krylov.r00t using gmail.com> wrote:
> >>
> >> > On Fri, 31 Jan 2020 17:02:16 -0600
> >> > Ana Marija <sokovic.anamarija using gmail.com> wrote:
> >> >
> >> > > I have a database DGN-WB_0.5.db is there is a way to explore its
> >> > > content in R?
> >> >
> >> > My psychic debugging powers tell me that it's an SQLite database, so
> >> > the answer to your question is: yes, it should be possible to both
> find
> >> > out the schema and run SQL queries on your file from R.
> >> >
> >> > --
> >> > Best regards,
> >> > Ivan
> >> >
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> ______________________________________________
> >> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >
> >
> >
> > --
> > John Kane
> > Kingston ON Canada
>
--
John Kane
Kingston ON Canada
More information about the R-help
mailing list