diff --git a/autopost/common.sh b/autopost/common.sh index 150e3ed..7ea20c7 100644 --- a/autopost/common.sh +++ b/autopost/common.sh @@ -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 -} \ No newline at end of file +} diff --git a/bin/postauto b/bin/postauto index 7abddd7..700af40 100644 --- a/bin/postauto +++ b/bin/postauto @@ -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 }