confidential-containers / simple-kbs

Key Broker Server for SEV(-ES)
Apache License 2.0
13 stars 13 forks source link

switch to sqlx for backend database handling #16

Closed jodh-intel closed 2 years ago

jodh-intel commented 2 years ago

The current code requires mysql/mariadb, but if we switched to sqlx we'd provide a more flexible solution that supports a lot more DB servers.

/cc @fitzthum.

fitzthum commented 2 years ago

@dunnderr something to think about once the db PR is merged.

dubek commented 2 years ago

Interesting suggestion @jodh-intel . Do you know if it will allow us to generate a binary that can work both with mysql and postgres? From their README, I see this comment:

    // Make a simple query to return the given parameter (use a question mark `?` instead of `$1` for MySQL)
    let row: (i64,) = sqlx::query_as("SELECT $1")
        .bind(150_i64)
        .fetch_one(&pool).await?;

If my code has to have ? or $1 in the queries then it cannot be used as-is to connect to different databases, I think.

dunnderr commented 2 years ago

I think that this sounds like a good idea. I will dig into the details of sqlx to see how we can migrate to sqlx from mysql.

dunnderr commented 2 years ago

I just posted a pull request incorporating sqlx that leverages any to support mysql, postgres, and sqlite.

fitzthum commented 2 years ago

30 merged.