mirror of
https://github.com/snachodog/sql_dump_split.git
synced 2025-04-21 19:22:24 -06:00
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.
This commit is contained in:
parent
ab4fadddbd
commit
991beaa9f0
27
split_sql_dump.bat
Normal file
27
split_sql_dump.bat
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user