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

Allow easy way to get Sqlite3 version #1122

Closed
code-ape opened this issue Dec 30, 2023 · 3 comments
Closed

Allow easy way to get Sqlite3 version #1122

code-ape opened this issue Dec 30, 2023 · 3 comments

Comments

@code-ape
Copy link

code-ape commented Dec 30, 2023

In working with better-sqlite3 we wanted to check the exact version of sqlite3 being used to ensure a feature was available or throw an error. There does not appear to be any way to get the sqlite3 version out of better-sqlite3 right now.

Suggestion of something like:

console.log(db.sqlite3Version)
// 3.44.2

Related Issues & PRs:

  1. Issue #5769: Sqlite support multi-value JSON insert knex/knex#5782
@Prinzhorn
Copy link
Contributor

#1021

@code-ape
Copy link
Author

Thanks @Prinzhorn, I've opened a PR which addresses both this and #1124:

@mceachen
Copy link
Member

mceachen commented Jan 1, 2024

fwiw, the built-in sqlite_version() function will return this value:

const bs = require("better-sqlite3");

function sqliteVersion() {
  let db;
  try {
    db = new bs(":memory:");
    return db.prepare("select sqlite_version()").pluck().get();
  } finally {
    db?.close();
  }
}

console.log(sqliteVersion());

Emits 3.44.2

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

No branches or pull requests

4 participants