New Vehicle Database
This commit is contained in:
67
data/make-model-import/import_data.sh
Executable file
67
data/make-model-import/import_data.sh
Executable file
@@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
# Import generated SQL files into PostgreSQL database
|
||||
# Run this after etl_generate_sql.py has created the SQL files
|
||||
|
||||
set -e
|
||||
|
||||
echo "=========================================="
|
||||
echo "📥 Automotive Database Import"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Check if Docker container is running
|
||||
if ! docker ps --filter "name=mvp-postgres" --format "{{.Names}}" | grep -q "mvp-postgres"; then
|
||||
echo "❌ Error: mvp-postgres container is not running"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✓ Docker container mvp-postgres is running"
|
||||
echo ""
|
||||
|
||||
# Check if output directory exists
|
||||
if [ ! -d "output" ]; then
|
||||
echo "❌ Error: output directory not found"
|
||||
echo "Please run etl_generate_sql.py first to generate SQL files"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run schema migration first
|
||||
echo "📋 Step 1: Running database schema migration..."
|
||||
docker exec -i mvp-postgres psql -U postgres -d motovaultpro < migrations/001_create_vehicle_database.sql
|
||||
echo "✓ Schema migration completed"
|
||||
echo ""
|
||||
|
||||
# Import engines
|
||||
echo "📥 Step 2: Importing engines (34MB)..."
|
||||
docker exec -i mvp-postgres psql -U postgres -d motovaultpro < output/01_engines.sql
|
||||
echo "✓ Engines imported"
|
||||
echo ""
|
||||
|
||||
# Import transmissions
|
||||
echo "📥 Step 3: Importing transmissions..."
|
||||
docker exec -i mvp-postgres psql -U postgres -d motovaultpro < output/02_transmissions.sql
|
||||
echo "✓ Transmissions imported"
|
||||
echo ""
|
||||
|
||||
# Import vehicle options
|
||||
echo "📥 Step 4: Importing vehicle options (56MB - this may take a minute)..."
|
||||
docker exec -i mvp-postgres psql -U postgres -d motovaultpro < output/03_vehicle_options.sql
|
||||
echo "✓ Vehicle options imported"
|
||||
echo ""
|
||||
|
||||
# Verify data
|
||||
echo "=========================================="
|
||||
echo "✅ Import completed successfully!"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "🔍 Database verification:"
|
||||
docker exec mvp-postgres psql -U postgres -d motovaultpro -c "SELECT COUNT(*) as engine_count FROM engines;"
|
||||
docker exec mvp-postgres psql -U postgres -d motovaultpro -c "SELECT COUNT(*) as transmission_count FROM transmissions;"
|
||||
docker exec mvp-postgres psql -U postgres -d motovaultpro -c "SELECT COUNT(*) as vehicle_count FROM vehicle_options;"
|
||||
echo ""
|
||||
docker exec mvp-postgres psql -U postgres -d motovaultpro -c "SELECT * FROM available_years;"
|
||||
echo ""
|
||||
echo "📊 Sample query - 2024 makes:"
|
||||
docker exec mvp-postgres psql -U postgres -d motovaultpro -c "SELECT * FROM get_makes_for_year(2024) LIMIT 10;"
|
||||
echo ""
|
||||
echo "✓ Database is ready for use!"
|
||||
Reference in New Issue
Block a user