Location of the sqlite database file

axum-login = "0.9.0"
cargo build
cargo run
everything works fine..
I can edit the database through the migration file..
but I do not know in what form and where it is the file (.db)..
I tried adding
const DB_URL: &str= "sqlite://sqlite.db";
error in output (file was not found)
app.rs

impl App {
    pub async fn new() -> Result<Self, Box<dyn std::error::Error>> {
        let db = SqlitePool::connect(":memory:").await?;
        sqlx::migrate!().run(&db).await?;

        Ok(Self { db })
    }

That means you're not using the file at all, you're using the in-memory representation.

3 Likes

if (SqlitePool::connect(":memory:")):
in fact: previous (cargo build) demolish clean = (cargo clean)
and new (cargo build) url str...
in python "sqlite+aiosqlite:///./db.sqlite3/" and rust .. ?

I have no idea what you are trying to say there and little about Sqlite but if I type "SqlitePool::connect( Rust" into google it soon finds a lot of tutorials and examples of how to do it with a file. For example:

let db_url = String::from("sqlite://sqlite.db");
    if !Sqlite::database_exists(&db_url).await.unwrap_or(false) {
        Sqlite::create_database(&db_url).await.unwrap();
        match cretea_schema(&db_url).await {
            Ok(_) => println!("Database created Sucessfully"),
            Err(e) => panic!("{}",e),
        }
    }
    let instances = SqlitePool::connect(&db_url).await.unwrap();
    let qry ="INSERT INTO settings (description) VALUES($1)";
    let result = sqlx::query(&qry).bind("testing").execute(&instances).await;

I've already seen all this and more..

Ah, good. Please do tell what exactly is the problem then?

2 Likes

after editing from (memory) to (url), build was infinite, still missed the wildcard (&).. I cleaned it up, started build from scratch and that's it.. Casuistry..

Ah, OK, got you. That is great.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.