0

I have to write REST API which will parse an SQLite file and parse&save its data into the server's MySQL DB.

The SQLite file will be passed as a .zip file(MultipartFile), so I have to unzip it, and then read the unzipped file as DTO.

The code will be as following..

fun parseSQLite(zipFile: MultipartFile) {
  val file = unzip(zipFile)

  val sqliteDB = somethingLibrary.load(file)

  doParseTable(sqliteDB.execute("select * from TestTable"))
}

I found there are sqlite-jdbc library(https://github.com/xerial/sqlite-jdbc), but it seems like it might not work in my case. I think I need mmap I/O, but are there any JAVA library for it?

Thanks!

mozzi
  • 63
  • 1
  • 10

1 Answers1

0

For those whom may face a similar problem; I decided to add a step that saves "unzipped SQLite DB" into the server's local storage, and then load DB from it.

it would be as to be following.

fun parseSQLite(zipFile: MultipartFile) {
  val fileName = unzipAndSaveToLocal(zipFile)
  
  val connection = DriverManager.getConnection("jdbc:sqlite:${testdir}/db/${fileName}");
  doParseTable(connection.createStatement().executeUpdate("select * from TestTable"))
}
mozzi
  • 63
  • 1
  • 10
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 26 '21 at 02:21