
Company News
Jerod Santo Joins Socket as Head of Media
Allow myself to introduce... myself.
This is a Web SQL library for use in the browser. Very useful in Electron and NW.js Apps, things that require complex queries. I know Web SQL is deprecated, but browsers have not yet announces it's removal so I am hoping it will stick around a long time or until they replace it with a relational database. It also might be worth checking out some alternatives like RxDB, PouchDB or sql.js.
This library is written with ES7 async await so using a browser that supports it is key.
Note: When using await you must used this library inside an async function. It is recommended having a decent amount of knowledge on SQLite3 which is what WebSQL is using in-browser.
async function init() {
const WebSQl = require('./websql')
const websql = new WebSQl(options)
await websql.connect(options)
}
let fields = [
websql.field({name: 'id', type: 'integer', index: 'PRIMARY KEY'}),
websql.field({name: 'idArtist', type: 'integer'}),
websql.field({name: 'title', type: 'integer'}),
websql.field({name: 'description', type: 'varchar', length: 255, default: ''}),
websql.field({name: 'entered', type: 'integer'}),
websql.field({name: 'updated', type: 'integer'})
]
let results
try {
results = await websql.tableCreate('album', fields, true)
} catch (err) {
console.log('Table Error', err)
}
Note The 3rd parameter is a boolean if you want to use IF NOT EXISTS.
List Tables
try {
let tables = await websql.tables()
} catch (err) {
console.log('Something WENT WRONG', err)
}
Check if Table Exists
try {
let bool = await websql.tableExists('album')
} catch (err) {
console.log('Something WENT WRONG', err)
}
List Table Fields
try {
let fields = await websql.tableFields('album')
} catch (err) {
console.log('Something WENT WRONG', err)
}
Drop a Table
try {
await tableDrop('album')
} catch (err) {
console.log('Something WENT WRONG', err)
}
When creating tables or listing fields the field object is always used. It consists of the following properties:
UNIQUE, PRIMARY KEY, KEYAuto Increment(SQLite3) Column Types:
BLOB, BOOL, CLOB, FLOAT, INTEGER, NUMERIC, REAL, VARCHAR, NVCHAR, TEXT
try {
const now = Math.floor(new Date().getTime() / 1000)
const idAlbum = await websql.insert('album', {
idArtist: 1,
title: 'Cows and Chickens',
description: 'This is really great!',
entered: now,
updated: now
}, false)
} catch (err) {
console.log('Something WENT WRONG', err)
}
Note The 3rd parameter is a boolean if you want to use IGNORE.
try {
await websql.update('album', 1, {
updated: Math.floor(new Date().getTime() / 1000)
})
} catch (err) {
console.log('Something WENT WRONG', err)
}
try {
const record = await websql.fetch('album', {id: 2})
} catch (err) {
console.log('Something WENT WRONG', err)
}
try {
const record = await websql.select('album', {idArtist: 1})
} catch (err) {
console.log('Something WENT WRONG', err)
}
let query = 'SELECT * FROM ' + websql.escapeField(table) + ' WHERE id > ?'
let values = [20]
try {
var results = await websql.query(query, values, true)
} catch (err) {
console.log('Something WENT WRONG', err)
return
}
for(var i = 0; i < results.row.length; i++)
console.log('row', i, results.rows.item(i))
Note The 3rd parameter is a boolean if you want processed results, false will return a SQLite results object.
try {
await websql.delete('album', {id: 1})
} catch (err) {
console.log('Something WENT WRONG', err)
}
FAQs
Web SQL library for use in the browser/electron/nwjs.
We found that lib-websql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.

Company News
Allow myself to introduce... myself.

Research
/Security News
A Twitch browser extension on Chrome and Firefox forwards users’ live OAuth session tokens through proxies controlled by a Russian bot service.

Security News
Anthropic found biased reasoning and recklessness drove Claude Mythos 5 to publish malware on PyPI and compromise a security vendor.