From 991beaa9f0879c80f827dce8df5991d16b547494 Mon Sep 17 00:00:00 2001 From: Steve Dogiakos Date: Sat, 30 Dec 2023 14:46:25 -0700 Subject: [PATCH] Add Windows Batch Script for SQL Dump Splitting This commit introduces a Windows batch (.bat) file as an alternative to the Python script for splitting SQL dumps. The batch script offers a convenient option for Windows users, especially those who prefer a quick, script-based solution without the need for Python. It reads a SQL dump file, identifies different databases, and creates separate SQL files for each database, ensuring ease of use and accessibility on Windows environments. --- split_sql_dump.bat | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 split_sql_dump.bat diff --git a/split_sql_dump.bat b/split_sql_dump.bat new file mode 100644 index 0000000..b194d48 --- /dev/null +++ b/split_sql_dump.bat @@ -0,0 +1,27 @@ +@echo off +setlocal enabledelayedexpansion + +REM Set your SQL dump file name here +set "SQL_DUMP_FILE=your_dump.sql" + +REM Variable to hold the current output file name +set "CURRENT_DB_FILE=" + +REM Read each line from the SQL dump +for /f "tokens=*" %%a in (%SQL_DUMP_FILE%) do ( + REM Check if the line contains the database name + echo %%a | findstr /c:"-- Database: " >nul + if !errorlevel! == 0 ( + REM Extract the database name and create a new file name + for /f "tokens=2 delims=`" %%b in ("%%a") do ( + set "CURRENT_DB_FILE=%%b.sql" + ) + ) + + REM If a current database file is set, append the line to it + if not "!CURRENT_DB_FILE!" == "" ( + echo %%a >> !CURRENT_DB_FILE! + ) +) + +endlocal