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 connection error? (title updated) #224

Closed
johalun opened this Issue Feb 20, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@johalun

johalun commented Feb 20, 2016

Hi! First of all, thanks for great job!

How can I change to sqlite backend? I can't find any documentation about this.

@johalun

This comment has been minimized.

johalun commented Feb 20, 2016

Ok, so just specifying a file as DATABASE_URL "diesel setup" and "diesel migration run" generates a database correctly but when I try the write_posts/read_posts (which works with pgsql) I get connection error:

[mirama@PC1-13-0006 diesel_demo$ cargo run --bin write_posts
Running target/debug/write_posts
thread '

' panicked at 'Error connecting to /home/mirama/dev/diesel_demo/diesel_demo.sqlite: BadConnection("missing "=" after "/home/mirama/dev/diesel_demo/diesel_demo.sqlite" in connection info string\n")', ../src/libcore/result.rs:746
note: Run with RUST_BACKTRACE=1 for a backtrace.
Process didn't exit successfully: target/debug/write_posts (exit code: 101)

@johalun johalun changed the title from sqlite backend? to sqlite connection error? Feb 20, 2016

@johalun johalun changed the title from sqlite connection error? to sqlite connection error? (title updated) Feb 20, 2016

@johalun

This comment has been minimized.

johalun commented Feb 20, 2016

Oh I see.. I have to use different API for sqlite :) That brings us to the next problem. infer_schema!() is not implemented for sqlite. What is the way to solve this with sqlite?

@mcasper

This comment has been minimized.

Collaborator

mcasper commented Feb 21, 2016

Hi @yohanesu75! You can definitely use a sqlite backend.

The CLI figures out what backend to use based on your DATABASE_URL, which is why it correctly used SQLite.

I'm pretty certain that the getting started demo is written all using Postgres, so a lot of it won't be compatible. It looks like you figured out to use the SqliteConnection struct instead of PgConnection, but you're correct, the infer_schema macro doesn't work for SQLite yet. I'm not entirely sure if infer_table_from_schema(table) works for SQLite, but I believe it doesn't work yet either. Instead you'll have to use the table! macro for each of your tables.

http://docs.diesel.rs/diesel/macro.table!.html

@sgrif

This comment has been minimized.

Member

sgrif commented Feb 21, 2016

You need to call table! directly for SQLite at the moment.

@sgrif sgrif closed this Feb 21, 2016

@johalun

This comment has been minimized.

johalun commented Feb 21, 2016

Thanks!

Sent from my iPhone

On Feb 21, 2016, at 06:45, Sean Griffin notifications@github.com wrote:

You need to call table! directly for SQLite at the moment.


Reply to this email directly or view it on GitHub.

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