Travel Agency Database Models
БесплатноНе проверенDatabase schema model change with prompts and automatic PR creation using GitHub Copilot
Описание
Database schema model change with prompts and automatic PR creation using GitHub Copilot
README
This repository contains Python SQLAlchemy model classes for a travel agency database schema. The models are designed to work with a MySQL database hosted on GibsonAI.
📋 Database Schema
The database consists of four main entities:
- TravelUser - Users of the travel agency platform
- TravelDestination - Available travel destinations
- TravelBooking - Bookings made by users for destinations
- TravelReview - Reviews written by users for destinations
🏗️ Model Structure
TravelUser
id- Primary key (auto-increment)uuid- Unique identifier for external referencesfirst_name,last_name- User's nameemail- Unique email addresspassword- Hashed passworddate_created,date_updated- Timestamps
Relationships:
bookings- One-to-many with TravelBookingreviews- One-to-many with TravelReview
TravelDestination
id- Primary key (auto-increment)uuid- Unique identifiername- Unique destination namedescription- Detailed descriptionprice- Price per person (Decimal)rating- Average rating 0.0-5.0date_created,date_updated- Timestamps
Relationships:
bookings- One-to-many with TravelBookingreviews- One-to-many with TravelReview
TravelBooking
id- Primary key (auto-increment)uuid- Unique identifieruser_id- Foreign key to TravelUserdestination_id- Foreign key to TravelDestinationbooking_date- When booking was madedate- Travel datestatus- Enum: 'pending', 'confirmed', 'cancelled'number_of_people- Number of travelersdate_created,date_updated- Timestamps
Relationships:
user- Many-to-one with TravelUserdestination- Many-to-one with TravelDestination
TravelReview
id- Primary key (auto-increment)uuid- Unique identifieruser_id- Foreign key to TravelUserdestination_id- Foreign key to TravelDestinationrating- Rating 1.0-5.0 (Decimal)comment- Optional review textreview_date- When review was submitteddate_created,date_updated- Timestamps
Relationships:
user- Many-to-one with TravelUserdestination- Many-to-one with TravelDestination
🚀 Installation
Install dependencies:
pip install -r requirements.txtSet up environment variables: Create a
.envfile with your database connection details:DATABASE_URL=mysql+pymysql://username:password@host:port/database # Or use individual components: DB_HOST=your-host DB_USER=your-username DB_PASSWORD=your-password DB_NAME=your-database DB_PORT=3306Initialize the database:
python database.py
💻 Usage Examples
Basic Usage
from models import TravelUser, TravelDestination, TravelBooking, TravelReview
from database import get_db_session
# Get a database session
session = get_db_session()
try:
# Create a new user
user = TravelUser(
first_name="John",
last_name="Doe",
email="[email protected]",
password="hashed_password"
)
session.add(user)
session.commit()
# Query users
users = session.query(TravelUser).all()
for user in users:
print(f"{user.full_name} - {user.email}")
finally:
session.close()
Using the DatabaseManager Utility
from database import get_db_session
from models import DatabaseManager
session = get_db_session()
db_ops = DatabaseManager(session)
try:
# Get user by email
user = db_ops.get_user_by_email("[email protected]")
# Get user's bookings
bookings = db_ops.get_user_bookings(user.id)
# Create a new booking
booking = db_ops.create_booking(
user_id=user.id,
destination_id=1,
travel_date=date(2024, 12, 25),
number_of_people=2
)
# Create a review
review = db_ops.create_review(
user_id=user.id,
destination_id=1,
rating=4.5,
comment="Amazing trip!"
)
finally:
session.close()
Model Properties and Methods
# User properties
user = session.query(TravelUser).first()
print(user.full_name) # "John Doe"
print(user.to_dict()) # Dictionary representation
# Destination properties
destination = session.query(TravelDestination).first()
print(destination.average_rating) # Calculated from reviews
print(destination.review_count) # Number of reviews
# Booking properties
booking = session.query(TravelBooking).first()
print(booking.total_price) # price * number_of_people
print(booking.is_upcoming) # True if date > today
print(booking.is_confirmed) # True if status is confirmed
# Review properties
review = session.query(TravelReview).first()
print(review.rating_stars) # "★★★★☆" visual representation
📁 File Structure
├── models.py # SQLAlchemy model definitions
├── database.py # Database connection and configuration
├── examples.py # Usage examples and sample data
├── requirements.txt # Python dependencies
└── README.md # This file
🛠️ Features
- Complete SQLAlchemy Models - Fully defined models with relationships
- Type Hints - Modern Python with type annotations
- Utility Methods - Convenient properties and methods on models
- Database Manager - Helper class for common operations
- Sample Data - Example data creation and queries
- Connection Management - Robust database connection handling
- GibsonAI Integration - Pre-configured for GibsonAI hosted databases
🔧 Configuration
The models are designed to work with the existing GibsonAI travel agency database schema. The connection string in database.py is pre-configured for the GibsonAI Production database:
# Default GibsonAI connection (replace with your actual credentials)
connection_string = "mysql+pymysql://us_PzN8AjvnKeSig5mgGZW:uWr90z6WZe9GPmbkOPMaPipYC4FDy5dz@production-mysql-assembly.cluster-colojrqwkt2v.us-east-1.rds.amazonaws.com/db_PzN8AjvnKeSig5mgGZW"
🧪 Running Examples
To see the models in action:
Create sample data:
# In examples.py, uncomment: create_sample_data()Run query examples:
# In examples.py, uncomment: query_examples()Try booking workflow:
# In examples.py, uncomment: booking_workflow_example()
📦 Dependencies
- SQLAlchemy 2.0+ - Modern Python SQL toolkit and ORM
- PyMySQL - Pure Python MySQL client
- python-dotenv - Environment variable management
- mysql-connector-python - Official MySQL driver
🤝 Contributing
These models are designed to be extensible. You can:
- Add new model methods and properties
- Extend relationships
- Add validation logic
- Create additional utility functions
- Implement caching or other optimizations
📄 License
This code is provided as an example for working with GibsonAI travel agency databases.
Установка Travel Agency Database Models
У этого сервера нет опубликованного пакета — он собирается из исходников. Открой репозиторий и следуй инструкции в README.
▸ github.com/Boburmirzo/travel-agency-database-modelsFAQ
Travel Agency Database Models MCP бесплатный?
Да, Travel Agency Database Models MCP бесплатный — установка в пару кликов через Unyly без оплаты.
Нужен ли API-ключ для Travel Agency Database Models?
Нет, Travel Agency Database Models работает без API-ключей и переменных окружения.
Travel Agency Database Models — hosted или self-hosted?
Self-hosted: сервер запускается локально на твоей машине командой из раздела установки.
Как установить Travel Agency Database Models в Claude Desktop, Claude Code или Cursor?
Открой Travel Agency Database Models на unyly.org, выбери вкладку своего клиента (Claude Desktop, Claude Code, Cursor) и нажми Install — конфиг сгенерируется автоматически, без правки JSON.
Похожие MCP
wenb1n-dev/SmartDB_MCP
A universal database MCP server supporting simultaneous connections to multiple databases. It provides tools for database operations, health analysis, SQL optim
автор: wenb1n-devPostgres Server
This server enables interaction with PostgreSQL databases through the Model Context Protocol, optimized for the AWS Bedrock AgentCore Runtime. It provides tools
автор: madhurprashPostgres
Query your database in natural language
автор: AnthropicPostgreSQL
Read-only database access with schema inspection.
автор: modelcontextprotocolRedis
Interact with Redis key-value stores.
автор: modelcontextprotocolSQLite
Database interaction and business intelligence capabilities.
автор: modelcontextprotocolmxcp
Open-source framework for building enterprise-grade MCP servers using just YAML, SQL, and Python, with built-in auth, monitoring, ETL and policy enforcement.
автор: raw-labstadas-github/a2asearch-mcp
MCP server to search 4,800+ MCP servers, AI agents, CLI tools and agent skills. Install: npx -y a2asearch-mcp. Ask Claude: "Find MCP servers for database access
автор: tadas-githubjulien040/anyquery
Query more than 40 apps with one binary using SQL. It can also connect to your PostgreSQL, MySQL, or SQLite compatible database. Local-first and private by desi
автор: julien040drakonkat/wizzy-mcp-tmdb
A MCP server for The Movie Database API that enables AI assistants to search and retrieve movie, TV show, and person information.
автор: drakonkatCompare Travel Agency Database Models with
Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории data
