Looking for an appropriate database

Lets say I have this code:

struct Customer
{
    id: u16,
    name: Name,
    age: u8,
    is_active: bool,
}

struct Name
{
    first: String,
    last: String,
}

fn main()
{
    let customer = Customer{name: Name{first: "John".to_string(), last: "Doe".to_string()},
    age: 32, is_active: false};
}

I want a simple database where it:

  • Supports Rust
  • I can easily save this and query data such as first name, especially the way how it is all structured
  • Supports structures such as like in my example where one of the field is linking to another structure

Not too sure which database to use. I was thinking about redb which is key-value pair but it seems like if you are trying to query something that is not the key (such as the first name), then this may be slow at retrieving your data, unless if I am mistaken?

Since you don't have experience with databases, a good place to start is to learn a little SQL and use SQLite, which is a great database and one of the simplest to use.

The queries you are asking about would be more difficult, but not impossible, with redb. Looks like you would have to roll-your-own secondaries by creating multiple tables to efficiently query by something other than the primary key. And there is no query language.

You can use many popular databases with Rust.

1 Like

Says who?

without first deserializing the data in a loop but that would be really slow afaik.

If you have experience, you can pick almost any database that you prefer from the list I posted. The requirements you posted were very general.

1 Like

I don't think you really understand what I am after. I don't want to use sql, I want something like a sea-orm approach in terms of syntax such as inserting and querying, except databases won't support columns where the data is like this name: Name, where the field is linking to another structure.

I don't know what you mean, I couldn't parse that sentence, sorry. If you look in the ORMs section of the link I posted you may find what you're looking for. If this isn't helpful, please just ignore it.

I will take a look at it thanks

I was looking for something like this:

Glad you found something.

I see it has a "Business Source License" now, but will switch to the Apache license later.

I also found another one:

this seems to be exactly what I want to use.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.