Skip to content

Chapter 5 failed, databaseurl changed #9

@developer-yl

Description

@developer-yl

I cannot even compile the code if I change the database user to a user that does not exist

DATABASE_URL=postgres://invaliduser:[email protected]:5432/truwitter

I get this error Failed to connect to the database: error returned from database: role "invaliduser" does not exist
Error: Custom { kind: Other, error: "Database connection failed" }

When I do a "cargo clean -p tutor-db"

I am unable to compile and get this error:

rror: error returned from database: role "invaliduser" does not exist
--> tutor-db/src/bin/../iter4/db_access.rs:7:23
|
7 | let course_rows = sqlx::query!(
| __________________^
8 | | "SELECT tutor_id, course_id, course_name, posted_time FROM ezy_course_c4 where tutor_id = $1",
9 | | tutor_id
10 | | )
| |
^
|
= note: this error originates in the macro $crate::sqlx_macros::expand_query which comes from the expansion of the macro sqlx::query (in Nightly builds, run with -Z macro-backtrace for more info)

error: error returned from database: role "invaliduser" does not exist
--> tutor-db/src/bin/../iter4/db_access.rs:31:22
|
31 | let course_row = sqlx::query!(
| ______________________^
32 | | "SELECT tutor_id, course_id, course_name, posted_time FROM
33 | | ezy_course_c4 where tutor_id = $1 and course_id = $2",
34 | | tutor_id, course_id
35 | | )
| |_____^
|
= note: this error originates in the macro $crate::sqlx_macros::expand_query which comes from the expansion of the macro sqlx::query (in Nightly builds, run with -Z macro-backtrace for more info)

error: error returned from database: role "invaliduser" does not exist
--> tutor-db/src/bin/../iter4/db_access.rs:49:22
|
49 | let course_row = sqlx::query!("insert into ezy_course_c4(
| ^
50 | | course_id, tutor_id, course_name) values ($1, $2, $3) returning
51 | | tutor_id, course_id, course_name, posted_time", new_course.course_id,
52 | | new_course.tutor_id, new_course.course_name)
| |
__________________________^
|
= note: this error originates in the macro $crate::sqlx_macros::expand_query which comes from the expansion of the macro sqlx::query (in Nightly builds, run with -Z macro-backtrace for more info)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions