0

I have downloaded the .sql file containing a database from mysql database. I want to load a particular table from the database into a dataframe in R.

I don't want to access the database directly but want to access downloaded database file.

  • 1
    look here https://stackoverflow.com/questions/44853322/how-to-read-the-contents-of-an-sql-file-into-an-r-script-to-run-a-query – D.J Aug 06 '21 at 12:18
  • The file format is well structured, and especially if you want to do it once and for a specific table where you know the structure in advance, you can write a simple parser for it. (And if you post your code where you try to do it yourself, and sample data, we can probably help you with that). In general though, read [this](https://stackoverflow.com/a/54132286). – Solarflare Aug 06 '21 at 12:52
  • Have you tried exporting the data you want into a .csv file? Those are far easier to handle than files containing a mess of SQL statements. – O. Jones Aug 06 '21 at 13:03

1 Answers1

0

You can load the SQL file into an SQLite database (which is a local database operating on a single file that runs without a server).

There is a script for converting a MySQL dump into something compatible with SQLite.

Once you have a SQLite database you can use the R connector.

Steohan
  • 476
  • 4
  • 6