Skip to content
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

DATABASE_URL not set #260

Closed
zhuxiujia opened this issue Apr 17, 2020 · 6 comments
Closed

DATABASE_URL not set #260

zhuxiujia opened this issue Apr 17, 2020 · 6 comments

Comments

@zhuxiujia
Copy link

DATABASE_URL not set

DATABASE_URL should not set in path!!!!

@abonander
Copy link
Collaborator

Can you please elaborate what the problem is? DATABASE_URL is an environment variable which is required to make query!() work as explained here: https://docs.rs/sqlx/0.3.4/sqlx/macro.query.html#requirements

It must be set at compile time, either using a .env file in the working directory of the application or just set in the environment that's invoking cargo.

@zhuxiujia
Copy link
Author

Can you please elaborate what the problem is? DATABASE_URL is an environment variable which is required to make query!() work as explained here: https://docs.rs/sqlx/0.3.4/sqlx/macro.query.html#requirements

It must be set at compile time, either using a .env file in the working directory of the application or just set in the environment that's invoking cargo.

way not use args to send to sqlx, use environment variable Too much trouble!

@abonander
Copy link
Collaborator

Why not send the database URL in the query!() invocation? It's not very useful to hard-code the database URL like that; you'd have to write it for every macro invocation, and change it for every location as well (for example, when deploying to production).

We are discussing a new macro_rules! macro which shadows query!() and the other macros with overrides for things like custom user types and changing the source for the database URL; that is ongoing in the following issue: #121

@zhuxiujia
Copy link
Author

zhuxiujia commented Apr 17, 2020

Why not send the database URL in the query!() invocation? It's not very useful to hard-code the database URL like that; you'd have to write it for every macro invocation, and change it for every location as well (for example, when deploying to production).

We are discussing a new macro_rules! macro which shadows query!() and the other macros with overrides for things like custom user types and changing the source for the database URL; that is ongoing in the following issue: #121

Well, I don't want to use environment variables, so I have to To give up this crate.
if can use lazy_static, or yaml some thing to config . it Easy to use

i think orm library should be keep easy. just like golang . you can run successful first time every module.
but this crate forced developers use environment. It was a terrible experience

so i say. This is a bit too dependent on compile time

@mehcode
Copy link
Member

mehcode commented Apr 17, 2020

I want to make it clear that the macro usage is entirely optional. There is a runtime-only API. Simple use query() or query_as() without the !.

You lose the compile time checking but I don't think you want that.

@mehcode
Copy link
Member

mehcode commented Apr 22, 2020

Closing as there is nothing actionable here. Please refer to #60 to track "offline" support for building with the macros.

@mehcode mehcode closed this as completed Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants