fix on dblog sql inserts
This commit is contained in:
parent
90cf89aed1
commit
d03539ce26
31
src/db.rs
31
src/db.rs
@ -83,14 +83,14 @@ pub fn insert(conn: &Connection, dblog: &DbLog) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DbLog {
|
pub struct DbLog {
|
||||||
serial: u16,
|
pub serial: u16,
|
||||||
time: String,
|
pub time: String,
|
||||||
latitude: f64,
|
pub latitude: f64,
|
||||||
longitude: f64,
|
pub longitude: f64,
|
||||||
speed: u16,
|
pub speed: u16,
|
||||||
height: u16,
|
pub height: u16,
|
||||||
direction: u16,
|
pub direction: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToSql for DbLog {
|
impl ToSql for DbLog {
|
||||||
@ -98,18 +98,3 @@ impl ToSql for DbLog {
|
|||||||
Ok(self.time.to_sql().unwrap())
|
Ok(self.time.to_sql().unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DbLog {
|
|
||||||
fn to_params(&self) -> &[&dyn ToSql; 7] {
|
|
||||||
let res = params![
|
|
||||||
self.time,
|
|
||||||
self.serial,
|
|
||||||
self.latitude,
|
|
||||||
self.longitude,
|
|
||||||
self.speed,
|
|
||||||
self.height,
|
|
||||||
self.direction
|
|
||||||
];
|
|
||||||
res
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -323,17 +323,16 @@ impl Message {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
let conn = connectdb().unwrap();
|
let conn = connectdb().unwrap();
|
||||||
insert(
|
let dblog = crate::db::DbLog {
|
||||||
&conn,
|
serial: inmsg.header.serial_number,
|
||||||
&inmsg.header.serial_number,
|
time: t.time.format("%Y-%m-%d %H:%M:%S").to_string(),
|
||||||
&t.time.format("%Y-%m-%d %H:%M:%S").to_string(),
|
latitude: t.latitude,
|
||||||
&t.latitude,
|
longitude: t.longitude,
|
||||||
&t.longitude,
|
speed: t.speed,
|
||||||
&t.speed,
|
height: t.height,
|
||||||
&t.height,
|
direction: t.direction,
|
||||||
&t.direction,
|
};
|
||||||
)
|
insert(&conn, &dblog).unwrap();
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user