This Docker-based FastAPI web application provides two conversion utilities:
- Converts SQL INSERT statements into PHP arrays
- Converts SQL CREATE TABLE statements into Laravel migrations
It offers a simple web interface with tabs for easy access to both features.
- Docker-containerized for easy deployment and consistency across environments
- Web-based interface with tabbed layout for easy access to both conversion utilities
- Converts SQL INSERT statements to PHP arrays
- Converts SQL CREATE TABLE statements to Laravel migrations
- Handles multiple tables in a single SQL file
- Properly manages NULL values and empty strings
- Returns the converted data as downloadable files (PHP file or ZIP file for migrations)
- Automatically cleans up temporary files
- Docker
- Docker Compose (optional, but recommended)
-
Clone this repository:
git clone https://github.com/yourusername/sql-converter.git cd sql-converter -
Build the Docker image:
docker build -t sql-converter .
-
Start the container:
docker run -d -p 8000:8000 sql-converter -
Open a web browser and navigate to
http://localhost:8000
-
Start the services defined in
docker-compose.yml:docker-compose up -d -
Open a web browser and navigate to
http://localhost:8000 -
Use the web interface to choose between SQL to PHP Array or SQL to Laravel Migration conversion
-
Upload your SQL file containing either INSERT or CREATE TABLE statements
-
The application will process the file and return a converted file for download (PHP file or ZIP file)
GET /: Renders the HTML page with tabs for both conversion optionsPOST /convert/php: Accepts a SQL file upload, converts INSERT statements to PHP arrays, and returns a PHP filePOST /convert/laravel: Accepts a SQL file upload, converts CREATE TABLE statements to Laravel migrations, and returns a ZIP file
app.py: Main application file containing the FastAPI app and all the logicDockerfile: Defines how to build the Docker image for this applicationdocker-compose.yml: Defines the services, networks, and volumes for Docker Composerequirements.txt: Lists the Python dependencies for the projectstatic/styles.css: CSS file for styling the web interfaceREADME.md: This file, containing project documentation
To make changes to the application:
- Modify the code in
app.pyorstatic/styles.css - Rebuild the Docker image:
docker build -t sql-converter . - Restart your container or Docker Compose services
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.