Skip to content

Is nolock option available? Accessing to file on WSL ends with error - SqliteError: database is locked #1394

@janproch

Description

@janproch

I have following script accessing file on WSL2:

import Database from 'better-sqlite3';

const db = new Database('\\\\wsl.localhost\\Ubuntu\\home\\jena\\demo.sqlite', { readonly: true, fileMustExist: true,  timeout: 5000 });

// list tables of SQLIte db
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table'").all();
console.log(tables);

It throws error:

C:\test\sqlitewsltest\node_modules\better-sqlite3\lib\methods\wrappers.js:5
        return this[cppdb].prepare(sql, this, false);
                           ^
SqliteError: database is locked
    at Database.prepare (C:\test\sqlitewsltest\node_modules\better-sqlite3\lib\methods\wrappers.js:5:21)
    at file:///C:/test/sqlitewsltest/index.mjs:15:19
    at ModuleJob.run (node:internal/modules/esm/module_job:271:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5) {
  code: 'SQLITE_BUSY'
}

File is not used on WSL, it was only created with sqlite commandline tool

It is possible to open database with nolock option?

Something like use this URL?

file://localhost//wsl.localhost/Ubuntu/home/jena/demo.sqlite?mode=ro&nolock=1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions