Better HN
topnewbestaskshowjobs
Log inSign up

groue

83 karma · joined Dec 2, 2011 (14y ago) · 66 submissions

[ my public key: https://keybase.io/groue; my proof: https://keybase.io/groue/sigs/knREShdojU_VyeRJ_ykxWtiYquBB3txRSZW2yAi4uAg ]
Submissions

comment 9mo ago · link · parent

Gentium is a very beautiful font: https://software.sil.org/gentium/

comment 1y ago · link · parent

You are not your code.

comment 1y ago · link · parent

Yes. GRDB encourages Codable because the user can profit from the code generated by the compiler, and this implies that database values are accessed by column name, on top of the Codable runtime, and those layers have a high cost. When necessary it is possible to access database values by position, and in this case GRDB achieves speed of light (performance nearly identical as raw SQLite).

comment 1y ago · link · parent

You're welcome :)

comment 1y ago · link · parent

Thank you (GRDB author here).

It is not mentioned in the README of the repository, but SQLiteData wraps GRDB to access the database and get notified of database changes (the meat and butter).

GRDB is by itself a solid "toolkit for SQLite databases, with a focus on application development", with both high levels APIs for everyday coding, and expert SQLite features for the demanding developers. Many apps rely on GRDB alone.

comment 2y ago · link · parent

Out of curiosity, I asked on the SQLite forum how the query optimizer fits in this schema: https://sqlite.org/forum/forumpost/93f9bfcec0

comment 4y ago · link · parent

I do, for JSON columns. I store UTF8 strings in SQLite, so that it is easy to see JSON values with a plain `SELECT *`). And I load blobs, because I code in Swift and the standard JSON decoder eats raw UTF8 memory buffers, not strings.

This avoids two useless conversions:

- first from a C string loaded from SQLite to a Swift Unicode string (with UTF8 validation).

- next from this Swift Unicode string to a UTF8 memory buffer (so that JSONDecoder can do its job).

SQLite is smart enough to strip the trailing \0 when you load a blob from a string stored in the database :-)

comment 4y ago · link · parent

Yes. Now, many short writes look exactly as one very long write from the point of view of an enqueued write that is waiting for its turn :-) I don't quite remember how fair is SQLite scheduling, in practice.

comment 4y ago · link · parent

What's cool with WAL mode is that SQLITE_BUSY won't happen for readers (except very rare scenarios: https://www.sqlite.org/wal.html#sometimes_queries_return_sql...)

One should only expect SQLITE_BUSY for writes (if a writer is already holding the lock, and the busy timeout expires before the other writer releases the lock). So yes, prefer short writes, or adjust your timeout. Generally speaking, SQLITE_BUSY can not be 100% prevented for writes.

comment 4y ago · link · parent

It is always safe, and by "safe" I mean "safe for data". You won't have to deal with data corruption. Precisely, see "How To Corrupt An SQLite Database File": https://www.sqlite.org/howtocorrupt.html

Now concurrent accesses from different processes/connections can lead to runtime errors (SQLITE_BUSY), because the database happens to be locked by one connection.

Those errors are greatly reduced by the WAL mode (https://sqlite.org/wal.html) which provides ultra-robust single-writer/multiple-readers semantics:

- Writes can not happen concurrently (SQLITE_BUSY).

- One can reduce the occurrences of such SQLITE_BUSY errors by using a built-in timeout (https://www.sqlite.org/c3ref/busy_timeout.html).

- Several reads can happen concurrently, including with writers.

- A writer connection can enter the "Serializable" isolation level.

- A reader connection can enter the "Snapshot Isolation" level.

For more details, see https://www.sqlite.org/isolation.html

During all the years I've been developing the GRDB library (https://github.com/groue/GRDB.swift), I could never see SQLite fail its documented guarantees. This made it possible to build one of the most concurrency-focused SQLite toolkit for Swift, and I'm pretty happy with it (https://github.com/groue/GRDB.swift/blob/master/Documentatio...).

comment 4y ago · link · parent

The music is quite good! The covers of Freddie Freeloader and Flamenco Sketches are quite worth it, IMHO :-)

comment 4y ago · link · parent

Library author here - SQLite concurrency needs a little care: don't miss the Concurrency Guide: https://github.com/groue/GRDB.swift/blob/master/Documentatio...

13.

GRDB 5.17 with async/await (SQLite toolkit for Swift)(old.reddit.com ↗)

1 points · by groue · 4y ago · 1 comment

comment 5y ago · link · parent

You can try https://github.com/groue/GRDB.swift

It's a thin wrapper around SQLite, with convenience APIs for record types, robust support for concurrency, and a focus on GUI apps.

15.

New release: GRDB 5.0.0 (Swift toolkit for SQLite databases)(forums.swift.org ↗)

1 points · by groue · 6y ago · discuss

16.

Swift Evolution – [Accepted] SE-0279: Multiple Trailing Closures(forums.swift.org ↗)

1 points · by groue · 6y ago · discuss

17.

Announcement: Version 5.0.0-beta of GRDB, the Swift toolkit for SQLite databases(forums.swift.org ↗)

1 points · by groue · 6y ago · discuss

18.

Announcing GRBD 4, a Swift Toolkit for SQLite Databases(forums.swift.org ↗)

1 points · by groue · 7y ago · discuss

comment 8y ago · link · parent

I often promise myself to have a look at SQLite virtual file system API, for this very purpose, but could not yet find the guts :-)

comment 8y ago · link · parent

We start to see ORMs like Diesel (https://diesel.rs) or GRDB (http://github.com/groue/GRDB.swift) that radically simplify their domain by removing traditional ORM features like implicit uniquing, lazy-loading, or auto-updates. This of course gives more work to do on the client side. But this work is positive and often simpler than expected. With traditional ORMs, there is still some work to do, which often looks like fights: against misunderstandings, against leaky abstractions, against configuration levels that don't match the needs of application, and generally speaking against the framework.

ORMs are not done yet :-)

comment 8y ago · link · parent

Related article: "Automatic Undo/Redo Using SQLite" https://www.sqlite.org/undoredo.html

comment 8y ago · link · parent

There are ORMs that address partial records, multi-threading troubles brought by lazy loading, uniquing, auto-updating records, and, importantly, put raw SQL on the same level as the query builder. I think of [Diesel](http://diesel.rs) and [GRDB.swift](https://github.com/groue/GRDB.swift/blob/master/Documentatio...).

comment 9y ago · link · parent

I agree. Sometimes, I explain that the feature request can be implemented, but not for free. I flag such issues with the "needs sponsoring" tag.

24.

SQLite: FMDB-compatible bindings to GRDB.swift(github.com ↗)

1 points · by groue · 9y ago · discuss

comment 9y ago · link · parent

Unique to GRDB.swift, as far as I know, is the ability to perform database writes and then wait until snapshot isolation has been reached in another connection before releasing the writing lock. This allows to read from a known database state, while allowing other writes to be performed. The ability to read for a precisely known database state allows nice features like database observation and reactive patterns, while taking advantage from the WAL mode by not holding locks longer than necessary.

comment 9y ago · link · parent

I'd also like to thank the other for his attempt at raising the general awareness of transaction isolation. Even when you deal with simpler databases like SQLite, isolation is a serious topic. When serializing accesses hinders performances, dealing with the "WAL mode" that grants SQLite with single-writer-multipler-readers abilities is everything but trivial, because of the huge amount of documentation that has to be read in order to reach the desired level of isolation. I've written an SQLite library in Swift that provides by default the snapshot isolation level which grants most developers with both peace of mind, and non-blocking reads. Check out its "concurrency guide" if you're interested: https://github.com/groue/GRDB.swift/blob/master/README.md#co...

comment 9y ago · link · parent

> They sound similar to change data capture in SQLServer.

Yes. There is a difference, though: SQLite is embedded, and there is zero latency between an application and its database.

This means that change notifications can be emitted synchronously right after a committed transaction, allowing the application to process the change before any other change could be performed.

This makes it much easier to get a very robust solution for a whole class of database synchronization problems.

comment 9y ago · link · parent

I didn't know about windowing function. This page looks like a nice description: https://community.modeanalytics.com/sql/tutorial/sql-window-...

29.

Unexpected SQLite with Swift(medium.com ↗)

1 points · by groue · 9y ago · 5 comments

comment 9y ago · link · parent

Sure, and French don't have a word for "entrepreneur" neither
123