2shady4u / godot-sqlite

GDExtension wrapper for SQLite (Godot 4.x+)
MIT License
947 stars 82 forks source link

Enable the use of shared in-memory databases #91

Closed cridenour closed 2 years ago

cridenour commented 2 years ago

I'm using a lot of threads in my game and prefer to use :memory: databases.

To properly thread SQLite I needed more connections - which for :memory: you need to switch to a URI opener: file::memory:?cache=shared

This required three small changes in the add-on, including an additional flag to sqlite3_open_v2. I can't imagine this has any drawbacks for other use-cases so I kept the flag on by default.

2shady4u commented 2 years ago

Hi @cridenour,

This seems to be a pretty straight-forward PR which I'll merge ASAP. According to the SQLite documentation as found here:

Since SQLite always interprets any filename that does not begin with "file:" as an ordinary filename regardless of the URI setting, and because it is very unusual to have an actual file begin with "file:", it is safe for most applications to enable URI processing even if URI filenames are not currently being used

Thank you for your contribution!