Skip to content

Nostr SQL databases #855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Nostr SQL databases #855

wants to merge 4 commits into from

Conversation

yukibtc
Copy link
Member

@yukibtc yukibtc commented Apr 30, 2025

Adds support for PostgreSQL, MySQL and SQLite backends.

@yukibtc yukibtc mentioned this pull request Apr 30, 2025
3 tasks
yukibtc pushed a commit that referenced this pull request Apr 30, 2025
This implements a basic driver for using Postgres, SQLite or MySQL as storage engine for nostr-database. Uses async Diesel as driver and Diesel migrations to set up the schema.

Pull-Request: #835
Pull-Request: #855
Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
@yukibtc
Copy link
Member Author

yukibtc commented Apr 30, 2025

@tompro, during local tests, I noticed that diesel requires the database URL for generating the rust schemas. Do you know if there is a way to generate schemas without have to connect to the database?

I found also sqlx, which also supports multiple backends, like diesel. Have you ever tried it or are you aware of the differences?
The nice thing of diesel is that, theoretically, supports SQLite for WASM, while sqlx doesn't seems to support WASM.

@yukibtc yukibtc added this to the Release v0.43 milestone Apr 30, 2025
@tompro
Copy link
Contributor

tompro commented Apr 30, 2025

@tompro, during local tests, I noticed that diesel requires the database URL for generating the rust schemas. Do you know if there is a way to generate schemas without have to connect to the database?

You probably mean for generating/updating the rust bindings (ORM mappings)? The thing is in Diesel this is done reverse. So first you run your migrations in a db instance and then re-import the bindings (diesel print-schema). This approach allows you to import a foreign schema from an existing db but it always requires a running database.

I found also sqlx, which also supports multiple backends, like diesel. Have you ever tried it or are you aware of the differences? The nice thing of diesel is that, theoretically, supports SQLite for WASM, while sqlx doesn't seems to support WASM.

I have been using sqlx but it is a low level driver where you mostly write queries in native SQL as there are no rust bindings. With the 'new' goal of supporting multiple databases I might have chosen to use it anyhow as there are almost no generics and derives involved. I think they even have code triggered migrations now. There is also SeqQL which puts a ORM on top of sqlx but when I checked it out last time it was not even close to Diesel.

@yukibtc yukibtc modified the milestones: Release v0.43, Release v0.44 May 12, 2025
tompro and others added 4 commits May 19, 2025 08:35
This implements a basic driver for using Postgres, SQLite or MySQL as storage engine for nostr-database. Uses async Diesel as driver and Diesel migrations to set up the schema.

Pull-Request: #835
Pull-Request: #855
Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants