A modern, responsive web application for managing books in an Oracle database using Flask, Bootstrap, and Docker.
python-oracle-docker/
βββ Dockerfile # Updated with Flask
βββ docker-compose.yml # Updated with web port mapping
βββ app.py # Flask web application
βββ templates/ # HTML templates directory
β βββ base.html # Base template with navigation
β βββ index.html # Main books listing page
β βββ add_book.html # Add new book form
β βββ edit_book.html # Edit existing book form
βββ README.md # This file
git clone https://github.com/search4asraful/python-oracle-docker.git
cd python-oracle-docker# Build the images
docker compose build
# Start Oracle database in background
docker compose up -d oracle-db
# Wait for database to be ready (check logs)
docker compose logs -f oracle-db
# Start the web application
docker compose up -d web-appOpen your browser and go to:
- Main Application: http://localhost:5000
- Oracle Enterprise Manager: http://localhost:5500/em (user: system, password: oracle)
Click on "Reset DB" in the navigation menu or visit http://localhost:5000/init to create the books table.
- Modern Bootstrap 5 Design: Professional, mobile-friendly interface
- Real-time Statistics: Dashboard showing total, available, and unavailable books
- Interactive Forms: Form validation and user feedback
- Flash Messages: Success/error notifications with auto-dismiss
- π View Books: Paginated list with search and filter options
- β Add Books: Form with validation and quick-fill examples
- βοΈ Edit Books: In-place editing with current data display
- ποΈ Delete Books: Confirmation dialogs for safe deletion
- Database Connection: Graceful handling of connection failures
- Input Validation: Client and server-side validation
- User Feedback: Clear error messages and success confirmations
- Clean, modern interface showing book statistics
- Responsive card layout with gradient backgrounds
- Quick action buttons and navigation
- User-friendly forms with real-time validation
- Character count indicators
- Quick-fill examples for faster data entry
- Professional table design with hover effects
- Status badges (Available/Unavailable)
- Action buttons for edit/delete operations
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Main books listing page |
| GET | /add |
Add new book form |
| POST | /add |
Submit new book data |
| GET | /edit/<id> |
Edit book form |
| POST | /edit/<id> |
Update book data |
| GET | /delete/<id> |
Delete book (with confirmation) |
| GET | /init |
Initialize database tables |
| GET | /health |
API health check |
# View application logs
docker compose logs -f web-app
# View database logs
docker compose logs -f oracle-db
# Restart web application only
docker compose restart web-app
# Stop all services
docker compose down
# Stop and remove volumes (fresh start)
docker compose down -v- Edit
templates/base.htmlto modify the overall theme - CSS variables for easy color scheme changes
- Bootstrap 5 utilities for rapid customization
Modify the table structure in app.py:
cursor.execute("""
CREATE TABLE books (
id NUMBER GENERATED BY DEFAULT AS IDENTITY,
title VARCHAR2(100),
author VARCHAR2(100),
available CHAR(1),
-- Add more columns here
PRIMARY KEY (id)
)
""")export FLASK_ENV=production
export ORACLE_USER=your_user
export ORACLE_PASSWORD=your_password
export ORACLE_HOST=your_host# Use production WSGI server
RUN pip install gunicorn
# Run with Gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]-
Database Connection Failed
- Check if Oracle container is running:
docker compose ps - Verify Oracle logs:
docker compose logs oracle-db - Wait for healthcheck to pass (can take 2-3 minutes)
- Check if Oracle container is running:
-
Web Interface Not Loading
- Check Flask container logs:
docker compose logs web-app - Verify port 5000 is not in use:
netstat -an | grep 5000
- Check Flask container logs:
-
Template Not Found
- Ensure templates directory exists and contains all HTML files
- Check file permissions and mounting in docker-compose.yml
If port 5000 is already in use, change it in docker-compose.yml:
ports:
- "8080:5000" # Use port 8080 insteadMIT License - feel free to use and modify for your projects.
This web interface transforms the command-line Oracle database operations into a full-featured web application with:
- Professional UI/UX with Bootstrap 5
- Responsive design that works on all devices
- Real-time form validation with visual feedback
- Interactive dashboard with statistics and quick actions
- Error handling with user-friendly messages
- RESTful endpoints for API integration
- Docker containerization for easy deployment
Perfect for learning Oracle database operations, Flask web development, and Docker containerization!