Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An example please. #3

Open
vvasuki opened this issue May 5, 2021 · 1 comment
Open

An example please. #3

vvasuki opened this issue May 5, 2021 · 1 comment

Comments

@vvasuki
Copy link

vvasuki commented May 5, 2021

Could you provide an example of usage (for example by correcting the below)?

  val db = DriverManager.getConnection("jdbc:sqlite:" + new File(filePath).toString).asInstanceOf[SQLiteConnection]
    db.open(allowCreate=true)
    try {
      var st = db.prepare(sql="CREATE TABLE IF NOT EXISTS definitions(headword TEXT PRIMARY KEY, definitions TEXT NOT NULL) WITHOUT ROWID")
      st.step()
    } finally {
      db.dispose()
    }


@david-bouyssie
Copy link
Owner

There no need to use a JDBC URL since JDBC is not used here.
Just provide a File instance directly.

val db = new SQLiteConnection(new File(filePath))
db.open(allowCreate=true)

// Custom PRAGMA definitions (optional)
//db.exec("PRAGMA temp_store=2;")
//db.exec("PRAGMA cache_size=-100000;") // around 100 Mo
//db.exec("PRAGMA mmap_size=2147418112;") 

try {
  db.exec("CREATE TABLE IF NOT EXISTS definitions(headword TEXT PRIMARY KEY, definitions TEXT NOT NULL) WITHOUT ROWID")
} finally {
  db.dispose()
}

I have not tested but this example should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants