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

SQLite Getting started/Skeleton app #376

Closed
stephanbuys opened this Issue Jul 11, 2016 · 10 comments

Comments

Projects
None yet
7 participants
@stephanbuys
Copy link

stephanbuys commented Jul 11, 2016

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.

@sgrif

This comment has been minimized.

Copy link
Member

sgrif commented Jul 11, 2016

Yes, it'd be good to have some example apps for both backends (probably after 0.7 releases 🔜 ™️)

@AndiDog

This comment has been minimized.

Copy link

AndiDog commented Oct 13, 2016

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".

@killercup

This comment has been minimized.

Copy link
Member

killercup commented Oct 13, 2016

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

@rogeruiz

This comment has been minimized.

Copy link

rogeruiz commented Nov 14, 2016

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. 😀

rogeruiz added a commit to rogeruiz/tick that referenced this issue Nov 16, 2016

Port over progress to leverage Diesel lib;
Now that I understand a bit more of `FromSqlRow`, its existence, and
what Nullable<Type> is, somewhat, I can probably port some of the things
in this guide and mash it up with what is currently in the guide for
Postgres for diesel-rs/diesel#376.

rogeruiz added a commit to rogeruiz/tick that referenced this issue Nov 21, 2016

Add save functionality; 👏
This helps put a major dent in diesel-rs/diesel#376. I was getting stuck
here most likely because of what's remaining on diesel-rs/diesel#130.
I'm not sure what differences SQLite has to Postgresql in terms of not
being about to use `get_result`, but the guide for diesel-rs/diesel#376
should either address the differences by suggesting you use `execute`
instead. Although, I'm not sure how to reproduce the functionality for
`get_result` using SQLite? Maybe a quick call to the database to
retrieve the latest one? We wouldn't know the id, so finding items in
the database would be almost impossible or at best super hacky.
@Frederick888

This comment has been minimized.

Copy link

Frederick888 commented Jan 7, 2017

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()?

@sgrif

This comment has been minimized.

Copy link
Member

sgrif commented Jan 7, 2017

You'll need to manually do a second query

@Frederick888

This comment has been minimized.

Copy link

Frederick888 commented Jan 7, 2017

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

@sgrif

This comment has been minimized.

Copy link
Member

sgrif commented Jan 7, 2017

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.

@killercup

This comment has been minimized.

Copy link
Member

killercup commented Feb 16, 2017

@Eijebong

This comment has been minimized.

Copy link
Member

Eijebong commented May 8, 2017

I think this can be closed now.

@Eijebong Eijebong closed this May 8, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment