1
0

inversion mysql -> sqlite par defaut

This commit is contained in:
unfr 2025-07-31 17:19:02 +02:00
parent beecdac997
commit f45cf6d29f
2 changed files with 6 additions and 7 deletions

View File

@ -37,13 +37,12 @@ NORMAL='\e[0m'
db_query() {
local sql="$1"
if [ "$dbtype" = "sqlite" ]; then
sqlite3 "$DB_FILE" "$sql"
else
# Le séparateur par défaut de --batch est tabulation
if [ "$dbtype" = "mysql" ]; then
mysql --batch --raw --default-character-set=utf8mb4 \
-h "$MYSQL_HOST" -P "$MYSQL_PORT" \
-u "$MYSQL_USER" -p"$MYSQL_PASS" \
-D "$MYSQL_DB" -e "$sql" | sed '1d' | tr '\t' '|'
else
sqlite3 "$DB_FILE" "$sql"
fi
}
}

View File

@ -8,14 +8,14 @@ checkdb() {
if [ "$dbtype" = "sqlite" ]; then
if [ ! -f "$DB_FILE" ]; then
echo "La base de données n'existe pas. Création..."
#do_createdb
do_createdb
fi
else
# Vérifie si la table existe, sinon crée-la
exists=$(db_query "SHOW TABLES LIKE 'release';")
if [ -z "$exists" ]; then
echo "La table 'release' n'existe pas. Création..."
#do_createdb
do_createdb
fi
fi
}