Diesel: SQLite Getting started/Skeleton app

Created on 11 Jul 2016  路  12Comments  路  Source: diesel-rs/diesel

Hi, would it be possible to build a branch of the skeleton app that uses SQLite? It seems like low-hanging fruit for lots of additional people to get going with Diesel as fast as possible. I banged my head on trying to convert the example app to use sqlite for a while but eventually gave up due to problems with the macros, and such.

documentation good first issue help wanted sqlite

Most helpful comment

I might just do a simple one, but first I need to resolve this issue:

.get_result(conn));
 ^^^^^^^^^^ trait `diesel::sqlite::Sqlite: diesel::backend::SupportsReturningClause` not satisfied

Even though it makes sense for an insert statement (since getting inserted rowid is another query), I need a solution for sqlite, e.g. .exec(conn) which doesn't get a "return value".

All 12 comments

Yes, it'd be good to have some example apps for both backends (probably after 0.7 releases :soon: :tm:)

I might just do a simple one, but first I need to resolve this issue:

.get_result(conn));
 ^^^^^^^^^^ trait `diesel::sqlite::Sqlite: diesel::backend::SupportsReturningClause` not satisfied

Even though it makes sense for an insert statement (since getting inserted rowid is another query), I need a solution for sqlite, e.g. .exec(conn) which doesn't get a "return value".

@AndiDog IIRC there is an execute(&connection) method you could use.

I may take a crack at this with my changes to rogeruiz/tick#4 which will be using SQLite. I hope the easy-for-newcomers label is the true in my case. 馃榾

I'm new to Diesel and still a little confusing with the SQLite. I know that we could use execute(conn) to execute the query, but how could I retrieve the created object without get_result()?

You'll need to manually do a second query

@sgrif So what is the equivalent call in Diesel as sqlite3_last_insert_rowid?

We don't expose that function, as its value cannot actually be relied on in all contexts. You can approximate its behavior by doing something like your_table.order(id.desc()).first(), which makes the caveats of sqlite3_last_insert_rowid more explicit and apparent.

I think this can be closed now.

So, if this issue is closed, where is the example now? And is it current?

@jhessin Examples for sqlite are here.

Was this page helpful?
0 / 5 - 0 ratings