ruscomap/script/inserisci_ricicla.sh

33 lines
1.3 KiB
Bash
Raw Permalink Normal View History

2024-11-02 02:33:17 +01:00
#!/bin/bash
2024-11-02 02:49:05 +01:00
#set -x
2024-11-02 02:33:17 +01:00
# Prendi credenziali db e tabella
DB_USER=$(jq -r '.db.user' ../server/config/default.json)
DB_PASS=$(jq -r '.db.password' ../server/config/default.json)
DB_NAME=$(jq -r '.db.database' ../server/config/default.json)
TABLE_NAME=$(jq -r '.db.table' ../server/config/default.json)
# Valori coords market ricicla
coordinates=(
"POINT(11.386956274509432 44.47601517125007)"
"POINT(11.373899281024935 44.484269124276224)"
"POINT(11.366094052791597 44.498236752697885)"
"POINT(11.352428197860718 44.51198490203542)"
2024-11-02 13:16:21 +01:00
"POINT(11.329773100000000 44.51429310000000)"
2024-11-02 02:33:17 +01:00
)
# Loop inserirmento ricicla
for i in "${coordinates[@]}"; do
2024-11-02 03:01:46 +01:00
# Genera dati riciclaq
2024-11-02 02:33:17 +01:00
NAME='Ricicla'
2024-11-02 03:01:46 +01:00
DESCRIPTION='Alimenti ancora buoni buttati vicino ai cassoneti dei supermercati da subito dopo chiusura. Maggiori info su: riciclabologna.vado.li'
2024-11-02 02:49:05 +01:00
FILENAME='riciclaimg'
2024-11-02 02:33:17 +01:00
COORDINATE="$i"
TS='2016-01-10 21:42:42'
# SQL command per inserire i dati
SQL_COMMAND="INSERT INTO $TABLE_NAME (name, description, filename, coordinate, ts) VALUES ('$NAME', '$DESCRIPTION', '$FILENAME', ST_GeomFromText('$COORDINATE'), '$TS');"
# Esegue inserimento
mysql -u "$DB_USER" -p"$DB_PASS" -D "$DB_NAME" -e "$SQL_COMMAND"
2024-11-02 02:49:05 +01:00
done