trying to add sqlx to the video_model
This commit is contained in:
parent
e0d7159328
commit
df07b13b28
3 changed files with 130 additions and 158 deletions
|
@ -240,19 +240,14 @@ pub mod song_model {
|
|||
}
|
||||
}
|
||||
|
||||
use crate::models::*;
|
||||
use crate::schema::songs::dsl::*;
|
||||
use crate::songs::song_editor::song_editor::QList_QString;
|
||||
use cxx_qt::{CxxQtType, Threading};
|
||||
use cxx_qt_lib::{
|
||||
QByteArray, QModelIndex, QString, QStringList, QVariant,
|
||||
};
|
||||
// use diesel::sqlite::SqliteConnection;
|
||||
use diesel::{delete, insert_into, prelude::*, update};
|
||||
use sqlx::{query, query_as, Connection, SqliteConnection};
|
||||
use std::collections::HashMap;
|
||||
use std::pin::Pin;
|
||||
use std::slice::Iter;
|
||||
use tracing::{debug, error};
|
||||
|
||||
use self::song_model::{
|
||||
|
@ -330,15 +325,7 @@ impl song_model::SongModel {
|
|||
}
|
||||
|
||||
pub fn setup(mut self: Pin<&mut Self>) {
|
||||
|
||||
let mut data = dirs::data_local_dir().unwrap();
|
||||
data.push("lumina");
|
||||
data.push("library-db.sqlite3");
|
||||
let mut db_url = String::from("sqlite://");
|
||||
db_url.push_str(data.to_str().unwrap());
|
||||
println!("DB: {:?}", db_url);
|
||||
static DATABASE_URL: &str = "sqlite:///home/chris/.local/share/lumina/library-db.sqlite3";
|
||||
let thread = self.qt_thread();
|
||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||
rt.block_on(async {
|
||||
let result = query_as!(Song, r#"SELECT vorder as "verse_order!", fontSize as "font_size!: i32", backgroundType as "background_type!", horizontalTextAlignment as "horizontal_text_alignment!", verticalTextAlignment as "vertical_text_alignment!", title as "title!", font as "font!", background as "background!", lyrics as "lyrics!", ccli as "ccli!", author as "author!", audio as "audio!", id as "id: i32" from songs"#).fetch_all(&mut self.as_mut().rust_mut().db).await;
|
||||
|
@ -393,10 +380,6 @@ impl song_model::SongModel {
|
|||
true
|
||||
}
|
||||
|
||||
fn get_db(self: Pin<&mut Self>) -> SqliteConnection {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn new_song(mut self: Pin<&mut Self>) -> bool {
|
||||
let song_id = self.rust().highest_id + 1;
|
||||
let song_title = String::from("title");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue