Live data from Hacker News

SQLite is not a toy database

antonz.org

171–180 of 364 posts

Re: SQLite is not a toy database

#171

With no sense of overstatement here, SQLite is one of my favorite creations in the entire world, so I have a bunch of links some of you might find interesting if you want to dig further: https://github.com/sql-js/sql.js - SQL.js lets you run SQLite within a Web page as it's just SQLite compiled to JS with Emscripten. https://litestream.io/blog/why-i-built-litestream/ - Litestream is a SQLite-powered streaming replica…

Using sql.js we have built online SQL course where the code is executed in the browser itself. https://academy.bigbinary.com/learn-sql

Re: SQLite is not a toy database

#172
post #16

> There is a popular opinion among developers that SQLite is not suitable for the web, because it doesn’t support concurrent access. No, the issue is it doesn't have high availability features: failover, snapshots, concurrent backups, etc. (Edit: oops, comment pointed out it does have concurrent backups.) SQLite isn't a toy DBMS, it's an extremely capable embedded DBMS. An embedded DBMS is geared towards serving a si…

For replication of SQLite there are some options:

http://litereplica.io - single-master replication

http://litesync.io - multi-master replication

https://aergolite.aergo.io - highest security replication, using a small footprint blockchain

Re: SQLite is not a toy database

#173
post #20

Earlier quoted context omitted.

SQLite is very limited because of its threading model, imo it's not usable outside of the single app model where you have a single user. https://sqlite.org/threadsafe.html https://sqlite.org/lockingv3.html

With a single thread & SQLite connection instance, I have been able to insert hundreds of thousands of rows per second when using NVMe drives. Note that WAL and synchronous flags must be set appropriately. Out of the box and using the standard "one connection per query" meme will handicap you to The trick for extracting performance from SQLite is to use a single connection object for all operations, and to serialize…

"The trick for extracting performance from SQLite is to use a single connection object for all operations, and to serialize transactions using your application's logic rather than depending on the database to do this for you."

It's not the right approach because it's hard to get right, you want to offload that to the DB.

Re: SQLite is not a toy database

#175
post #7

Does anyone use SQLite as their daily-driver in lieu of R or pandas for data analysis? I don't think I can use the sqlite command-line since I'd want a fully-developed plotting utility, and it seems less convenient to do the actual analysis part through a sqlite connection in python, say.

I use extensively DbBrowser for sqlite to plot simple graph from sql queries of imported csv files, it is easier than to start a jupyter environment with python and pandas or r studio.

Re: SQLite is not a toy database

#176

Is it the unix version of MS Access? It's sort of interesting to compare the two.

Well the database part maybe, but it's not going to help you generate forms and reports or build small guis around it. You'll have to find those tools for yourself or build a web app around your sqlite db. I haven't done a lot with Access though, mostly help build small database interfaces/reports for their inventory systems (whether a lab or comic book collection).

You can do all that with tcl/tk. Sqlite was in fact originally a tcl extension so the tcl interface for sqlite is first-rate. With tcl/tk it's sort of a Unix analog to VB6.

I keep thinking it would be sort of fun to do a tk app again; is there a good model CRUD app for tcl/tk/sqlite out there? Something like the Northwind thing for Access?

Re: SQLite is not a toy database

#177
post #173

Earlier quoted context omitted.

With a single thread & SQLite connection instance, I have been able to insert hundreds of thousands of rows per second when using NVMe drives. Note that WAL and synchronous flags must be set appropriately. Out of the box and using the standard "one connection per query" meme will handicap you to The trick for extracting performance from SQLite is to use a single connection object for all operations, and to serialize…

"The trick for extracting performance from SQLite is to use a single connection object for all operations, and to serialize transactions using your application's logic rather than depending on the database to do this for you." It's not the right approach because it's hard to get right, you want to offload that to the DB.

It's actually not that hard to get right. You can put a simple lock statement around a SQLiteConnection instance to achieve the same effect with 100% reliability, but with dramatically lower latency than what hosted SQL offerings can provide.

Also, the only reason we ever want to lock a SQLiteConnection is to obtain a consistent LastInsertRowId. With the latest changes to SQLite, we don't even have to do this anymore as we can return the value as part of a single invocation.

Re: SQLite is not a toy database

#178

Two major gripe I had with SQlite 1. SQLite doesn't really enforce column types[0], the choice is really puzzling to me. Since schema enforced type check is one of the strong suit of SQL/RDMBS based data solution. 2. Whole database lock on write, this make it unsuitable to high write usages like logging and metric recording. WAL mode will help but it will only alleviate the issue, you will need row based lock solutio…

> SQLite doesn't really enforce column types[0], the choice is really puzzling to me.

This is acknowledged as a likely mistake, but one that will never be fixed due to backward compatibility:

> Flexible typing is considered a feature of SQLite, not a bug. Nevertheless, we recognize that this feature does sometimes cause confusion and pain for developers who are acustomed to working with other databases that are more judgmental with regard to data types. In retrospect, perhaps it would have been better if SQLite had merely implemented an ANY datatype so that developers could explicitly state when they wanted to use flexible typing, rather than making flexible typing the default. But that is not something that can be changed now without breaking the millions of applications and trillions of database files that already use SQLite's flexible typing feature.

https://sqlite.org/quirks.html

Re: SQLite is not a toy database

#179
> There is nothing more convenient than SQLite for analyzing and transforming JSON.

the example query given:

    select
      json_extract(value, '$.iso.code') as code,
      json_extract(value, '$.iso.number') as num,
      json_extract(value, '$.name') as name,
      json_extract(value, '$.units.major.name') as unit
    from
      json_each(readfile('currency.sample.json'))
    ;
that sure looks fun to type into a repl!

nothing against sqlite, which I like and use, just found the idea of that query being convenient for one-off analysis to be off.

Re: SQLite is not a toy database

#180
post #144

Earlier quoted context omitted.

Check out rqlite ( https://github.com/rqlite/rqlite ) for that functionality - "rqlite is a lightweight, distributed relational database, which uses SQLite as its storage engine. Forming a cluster is very straightforward, it gracefully handles leader elections, and tolerates failures of machines, including the leader. rqlite is available for Linux, macOS, and Microsoft Windows."

To me this is obviating a lot of the advantage of SQLite over any other RDBMS.

I thought the same, but maybe it's useful if you start with SQLite and decide to scale up to a distributed RDBMS without having to rewrite too much?
Post reply on HN