fix on insert query
This commit is contained in:
parent
d03539ce26
commit
31d16cc192
@ -36,7 +36,7 @@ function update(data) {
|
||||
let section = parseInt(data.direction/45 + 0.5);
|
||||
section = section % 8;
|
||||
console.log(arrows[section]);
|
||||
const text = `${data.time}<br/>height: ${data.height}<br/>speed: ${speed}<br/>direction: ${arrows[section]} ${data.direction}`;
|
||||
const text = `time: ${data.time}<br/>latitude: ${data.latitude}<br/>longitude: ${data.longitude}<br/>height: ${data.height}<br/>speed: ${speed}<br/>direction: ${arrows[section]} ${data.direction}`;
|
||||
if (!map) {
|
||||
create_map(coords);
|
||||
} else {
|
||||
|
12
src/db.rs
12
src/db.rs
@ -19,21 +19,21 @@ CREATE INDEX idx_time
|
||||
const QUERY_INSERT: &'static str = "
|
||||
INSERT INTO log (
|
||||
time,
|
||||
serial,
|
||||
latitude,
|
||||
longitude,
|
||||
speed,
|
||||
height,
|
||||
direction
|
||||
direction,
|
||||
serial
|
||||
)
|
||||
VALUES (
|
||||
:time,
|
||||
:serial,
|
||||
:latitude,
|
||||
:longitude,
|
||||
:speed,
|
||||
:height,
|
||||
:direction
|
||||
:direction,
|
||||
:serial
|
||||
)";
|
||||
|
||||
pub fn connectdb() -> Result<Connection> {
|
||||
@ -69,13 +69,13 @@ pub fn prepare_insert(conn: &Connection) -> Statement {
|
||||
pub fn insert(conn: &Connection, dblog: &DbLog) -> Result<()> {
|
||||
let mut stmt = prepare_insert(&conn);
|
||||
match stmt.execute(params![
|
||||
dblog.serial,
|
||||
dblog.time,
|
||||
dblog.latitude,
|
||||
dblog.longitude,
|
||||
dblog.speed,
|
||||
dblog.height,
|
||||
dblog.direction,
|
||||
dblog.serial,
|
||||
]) {
|
||||
Ok(i) => println!("{} rows were inserted", i),
|
||||
Err(err) => println!("insert failed: {}", err),
|
||||
@ -84,13 +84,13 @@ pub fn insert(conn: &Connection, dblog: &DbLog) -> Result<()> {
|
||||
}
|
||||
|
||||
pub struct DbLog {
|
||||
pub serial: u16,
|
||||
pub time: String,
|
||||
pub latitude: f64,
|
||||
pub longitude: f64,
|
||||
pub speed: u16,
|
||||
pub height: u16,
|
||||
pub direction: u16,
|
||||
pub serial: u16,
|
||||
}
|
||||
|
||||
impl ToSql for DbLog {
|
||||
|
Loading…
Reference in New Issue
Block a user