📅 Day 14/30 — BookStore-Management-API(FastAPI + MySQL) 🔹 Project Overview: Built a complete BookStore-Management-API using Python (FastAPI) and MySQL. The system enables users and sellers to interact through a role-based structure, allowing book management, purchasing, and real-time business insights via an admin dashboard. 🔹 Tools Used: Python (FastAPI) | MySQL | SQLAlchemy 🔹 Key Features: • Role-based user system (User & Seller) 👥 • Book management system (add, update stock) 📚 • Purchase system with stock validation 🛒 • Admin dashboard with business metrics 📊 • Revenue tracking (total & daily) 💰 • Clean API design with form-based inputs ⚡ 🔹 What I Learned: • Designing REST APIs using FastAPI • Connecting Python with MySQL using SQLAlchemy • Implementing role-based logic in backend systems • Handling real-world scenarios like stock & transactions • Building admin analytics for business insights 🔗 GitHub Repository: https://lnkd.in/d4XAJZ2W #DataAnalytics #FastAPI #PythonProjects #SQL #BackendDevelopment #30DaysOfCoding 🚀
More Relevant Posts
-
Day 3: SQLite, SQLAlchemy & Alembic CRUD needs some memory, and that's what day 3 is about. We swap out the in-memory Python list for a real SQLite database — adding SQLAlchemy as the ORM and Alembic to manage schema changes over time. If you've used Eloquent + Laravel migrations, the mental model is nearly identical. Here's what we cover: → Setting up SQLAlchemy's three core pieces: engine, session factory, and declarative base → Defining ORM models with a one-to-many relationship (tasks → notes) and cascade deletes → Wiring Alembic so autogenerate actually works (the __init__.py trick that trips everyone up) → The session lifecycle: why db.commit() is the single most common mistake → Running a real schema migration — adding a column to a live database without touching the file directly The part worth highlighting: the service/route separation from Day 2 paid off immediately. The routes layer barely changed. The database swap was almost entirely contained to the service layer. That's the point of keeping them separate. By the end, you stop the server, restart it, and your data is still there. 👉🏼 Read the full article - link is in the comments. #Python #Starlette #SQLAlchemy #WebDevelopment #BackendDevelopment
To view or add a comment, sign in
-
🚀 Built Lightweight Async ORMs for FastAPI (Inspired by LoopBack) While working on FastAPI projects, I got an idea based on my previous experience with LoopBack — what if we could have a simpler ORM with: minimal boilerplate built-in relation loading and straightforward query syntax So I built two async ORMs: oceanic-mysql-orm — built on aiomysql oceanic-postgres-orm — built on asyncpg 💡 Key Features Async-first (no session management) Automatic relation loading (no N+1 issues) Auto-migrate (additive only — never drops columns) Simple dict-based query system SQL echo mode for debugging ⚡ Example users = await connector.find(User, { "where": {"status": "active"}, "include": ["posts"], "limit": 20 }) 🔥 PostgreSQL Extras Soft deletes (deleted_at handled automatically) Raw SQL support when needed Nested includes (orders.items.product) Advanced filters (ilike, regexp, between) ⚠️ Scope This is intentionally designed for simplicity: No complex JOIN builder No multi-database abstraction SQLAlchemy is still a great choice for large, complex systems. This is aimed at the 80% use case where you want to build and ship quickly. 📦 Installation pip install oceanic-mysql-orm pip install oceanic-postgres-orm 🚧 Status Both packages are v1 (early stage). They’re functional, but I’d really value feedback from developers working with FastAPI. 🔗 Full Guide Complete usage guide here: https://lnkd.in/dj5eY4aN
To view or add a comment, sign in
-
𝐖𝐡𝐚𝐭 𝐢𝐟 𝐲𝐨𝐮 𝐧𝐞𝐯𝐞𝐫 𝐡𝐚𝐝 𝐭𝐨 𝐰𝐫𝐢𝐭𝐞 𝐫𝐚𝐰 𝐒𝐐𝐋 𝐚𝐠𝐚𝐢𝐧? That's Django's ORM (Object-Relational Mapper) in a nutshell. An ORM lets you interact with your database using Python instead of SQL. You define your data as Python classes (called models), and Django handles the database queries behind the scenes. Here's a simple example: Instead of writing: SELECT * FROM blog_post WHERE author_id = 1; You write: Post.objects.filter(author_id=1) Same result. Pure Python. No SQL dialect to worry about. What makes the Django ORM powerful: → Works with PostgreSQL, MySQL, SQLite, Oracle. Same code, different DB → Migrations: Change your model, run a command, database updates automatically → Querysets that are chainable, lazy, and incredibly readable → Relationships like ForeignKey, ManyToMany, OneToOne, all handled elegantly I've worked with Oracle 19c and PostgreSQL in production. The ORM made switching between them painless which required just a config change. The caveat? For very complex queries, raw SQL is still available. The ORM doesn't replace SQL knowledge. It reduces how often you need it. If you're building data-heavy apps, learning the Django ORM deeply is one of the best investments you can make. Tomorrow: Django REST Framework, turning Django into an API powerhouse. #Django #ORM #Python #BackendDevelopment #Database
To view or add a comment, sign in
-
-
Day 66 of #90DaysOfCode Today I built a Flask web application to manage a personal book library using SQLite and SQLAlchemy. This is my first project where I integrated a database instead of relying on file-based storage, which made the application more structured and scalable. The app allows users to add books with title, author, and rating, and stores them in a database that is dynamically rendered on the homepage. Key features implemented • SQLite database integration • SQLAlchemy ORM for data modeling • Dynamic data retrieval and rendering • Form handling with validation • Backend data persistence Key concepts learned • How databases integrate with backend applications • Using ORM instead of manual file handling • Structuring models using SQLAlchemy • Managing and querying persistent data This project gave me a much clearer understanding of how real-world applications manage data. GitHub Repository https://lnkd.in/gTAqTzFW #Python #Flask #SQLAlchemy #BackendDevelopment #WebDevelopment #90DaysOfCode
To view or add a comment, sign in
-
my FastAPI Journey — Database Integration with SQLAlchemy! Until now I was storing data in a Python list — which gets wiped every time the server restarts! 😅 Today I connected FastAPI to a real database using SQLAlchemy + SQLite — and data is now PERMANENT! 🎉 🔥 What I built today: A fully functional Notes API connected to a real database with complete CRUD operations! ✅ What I implemented: 📌 SQLite Database — Simple file based database (notes.db) that stores data permanently on disk 📌 SQLAlchemy ORM — Connects Python to database without writing any raw SQL! 📌 Database Models — Defined Note table with id, title, content, priority and tag columns 📌 Pydantic Schemas — Separate models for input validation and response formatting 📌 Dependency Injection — Used FastAPI's Depends() to manage database sessions cleanly 📌 Full CRUD API: → POST /notes — Create and save note to database → GET /notes — Fetch all notes from database → GET /notes/{id} — Fetch specific note by ID → DELETE /notes/{id} — Delete note from database 💡 Key concepts I learned: 🔹 SQLAlchemy Engine — Creates connection to the database file 🔹 SessionLocal — Manages database transactions safely 🔹 Base.metadata.create_all() — Auto creates tables, no migrations needed! 🔹 db.add() → db.commit() → db.refresh() — The 3 steps to save data 🔹 response_model — Controls exactly what data is returned to user 🔹 from_attributes = True — Allows Pydantic to read SQLAlchemy objects directly ⚡ Best part? Restarted the server → data was still there! 🎉 This is the magic of a real database vs a Python list! Compare with Django: → Django makemigrations → FastAPI create_all() automatic! → Django objects.create() → FastAPI db.add() + db.commit() → Django serializers → FastAPI Pydantic schemas Next up: 🔐 Module 5 — JWT Authentication & Security 🚀 Module 6 — Advanced FastAPI Features 🌍 Module 8 — Deploying to Production Learning in public — follow along for daily updates! 💪 #FastAPI #Python #SQLAlchemy #Database #SQLite #BackendDevelopment #Django #LearningInPublic #100DaysOfCode #WebDevelopment #API #SoftwareEngineering
To view or add a comment, sign in
-
Day 10/30 — Social Network Analyzer (Python + MySQL) 🔹 Project Overview: Developed a Social Network Analyzer system using Python and MySQL to model user relationships, analyze connections, and recommend new links using graph-based algorithms. 🔹 Tools Used: Python | MySQL | Data Structures | Graph Algorithms | NetworkX | Matplotlib 🔹 Key Features: • Designed relational database to manage users and connections • Built graph structure to represent real-world relationships • Implemented BFS to find shortest connection paths • Identified mutual connections between users • Developed recommendation engine based on shared connections • Added network visualization for interactive analysis • Created CLI-based interface with clean and colored output 🔹 What I Learned: • Applying graph algorithms in real-world scenarios • Working with MySQL for structured data management • Building scalable backend logic using Python • Visualizing relationships using network graphs • Designing modular and maintainable code 🔗 GitHub Repository: https://lnkd.in/dpSCzhQG Would appreciate your feedback and suggestions 🙌 #30DaysOfCoding #PythonProjects #SQL #DataStructures #BackendDevelopment #LearningByDoing
To view or add a comment, sign in
-
🚀 Excited to announce the launch of **pandasv2** – a production-ready Python library solving critical pain points when using pandas DataFrames in web applications! ## The Problem Working with pandas in web frameworks creates three headaches: - ❌ JSON serialization fails with NumPy types (int64, float64) - ❌ Silent data loss when converting to JSON (dates become timestamps, precision lost) - ❌ Manual conversion code scattered across your codebase ## The Solution **pandasv2** provides: ✅ **One-line JSON serialization** – Automatic handling of NumPy/pandas types (int64, float64, NaT, NaN) ✅ **Zero-config framework integration** – FastAPI, Flask, Django support out of the box ✅ **Type-safe round-trip conversion** – Serialize and deserialize with 100% fidelity ✅ **3-5x performance boost** – Faster than manual conversion methods ✅ **Production-ready** – Full test coverage, comprehensive documentation, MIT licensed ## Real-World Example ```python from fastapi import FastAPI import pandas as pd import pandasv2 app = FastAPI() @app.get("/data") def get_data(): df = pd.read_csv("data.csv") return pandasv2.FastAPIResponse(df) # ✅ Just works! ``` **Now available on PyPI:** pip install pandasv2 🔗 GitHub: https://lnkd.in/dfDMF8Gx 📚 Docs: https://lnkd.in/dqsPkAVa If you've struggled with pandas + JSON serialization, give pandasv2 a try and let me know what you think! #Python #DataScience #WebDevelopment #OpenSource #FastAPI #Pandas #JSON
To view or add a comment, sign in
-
An API endpoint was making 401 database queries. Every. Single. Request. Day 15 of 30 -- SQLAlchemy ORM Internals Phase 3 -- Backend and APIs Nobody noticed for weeks. The dashboard just felt slow. The fix: 4 lines of code. One selectinload. One joinedload. Down to 3 queries. 3.2 seconds to 31 milliseconds. The culprit was the N+1 problem. When you fetch 50 orders and access order.customer in a loop, SQLAlchemy fires a separate SELECT for each customer. 50 orders = 51 queries. Add items and products and you get 401 queries per page load. Today's Topic covers: Identity Map and Unit of Work -- the two patterns that explain 90% of SQLAlchemy behavior 4 session states -- Transient, Pending, Persistent, Detached and what each means The N+1 problem with a visual query trace -- 401 queries vs 3 6 loading strategies -- lazy, joinedload, selectinload, subqueryload, raiseload, noload When to use joinedload vs selectinload -- the to-one vs to-many rule Full annotated syntax -- model definition, eager loading chains, unit-of-work commit Real order dashboard -- 401 queries reduced to 3 with 4 lines of options() 5 mistakes including DetachedInstanceError and joinedload on to-many 5 best practices including lazy=raise as the production default Key insight: Every ORM hides SQL from you. The good engineers know exactly what SQL their ORM is generating -- and why. #Python #SQLAlchemy #ORM #BackendDevelopment #Database #100DaysOfCode #FastAPI #TechContent #BuildInPublic #TechIndia #SoftwareEngineering #LinkedInCreator #LearnPython #OpenToWork #DataEngineering #PythonTutorial
To view or add a comment, sign in
-
Day 3 – Grocery Store Practice Project (FastAPI) Today I worked on building the product & category management system using FastAPI, SQLAlchemy, and Jinja2 templates. - Database Setup I used SQLAlchemy to automatically create database tables: Connected models with the database Ensured tables are created using Base.metadata.create_all() - Homepage ("/") Fetched all categories from the database Rendered them dynamically on the homepage using Jinja2 templates - Templates (Frontend with Jinja2) - Created templates for: Adding new products (add_product.html) Displaying all products (dashboard.html) - Used dynamic data rendering to show categories, products, and images - Add Product (GET & POST) - Created a form to add new products - Fetched categories dynamically for selection - Handled form submission with: Product name, price, stock, description Category selection Multiple image uploads - Stored product data in database - Saved uploaded images to static/uploads - Linked images with products using relationships - Add Category Created a separate endpoint to add categories Uploaded category images Stored image paths in database Redirected user after successful submission - Dashboard Page Displayed all products Displayed associated product images - Key Concepts I Practiced Today: FastAPI routing (GET & POST) Dependency Injection (Depends) File handling (UploadFile, saving images) SQLAlchemy ORM (add, commit, refresh) Template rendering with Jinja2 Handling relationships between tables Slowly building a full-stack FastAPI application step by step! Here is My Github Project Repository: https://lnkd.in/dhmP-BeX #FastAPI #Python #WebDevelopment #Backend #SQLAlchemy #LearningJourney
To view or add a comment, sign in
-
Everyone talks about MCP. Almost nobody actually builds one. Here is how to build your first MCP server and connect it to Claude (~1 hour) Save this post. You will need it. What is MCP in 1 sentence? It is USB-C for AI. One protocol, any tool. Build it once, and it works with Claude, ChatGPT, Cursor, and any other MCP-compatible client. 1️⃣ The Basics (5 min) 🔹 Install Claude Desktop. 🔹 Install Node.js 18+ or Python 3.10+. 🔹 Pick an SDK: Use Python + FastMCP for your first server. It has the least boilerplate. 2️⃣ Create the project (5 min) 🔹 Bash mkdir my-mcp-server cd my-mcp-server pip install fastmcp Create main. py: 🔹 Python from fastmcp import FastMCP mcp = FastMCP("my-first-server") @mcp.tool() def add_numbers(a: int, b: int) -> int: """Add two numbers together.""" return a + b if __name__ == "__main__": mcp. run() That is it. You have a functioning MCP server. 3️⃣ Connect to Claude (5 min) Open your claude_desktop_config.json: Mac: ~/Library/Application Support/Claude/ Windows: %APPDATA%\Claude\ Add this block: JSON { "mcpServers": { "my-first-server": { "command": "python", "args": ["/absolute/path/to/main. py"] } } } Restart Claude. Ask it: "add 5 and 7 using my tool." 4️⃣ Make it useful (30 min) The calculator is a toy. Replace it with something real - wrap a GitHub API, connect to your local DB, or link your internal docs. The pattern is always: 🔹 Define a tool with @mcp.tool(). 🔹 Write a clear description (Claude uses this to decide when to trigger it). 🔹 Return structured data. Mistakes I made (so you don't have to): 🔹 Never use print() or console.log() in stdio servers. It breaks the protocol. 🔹 Use logging to stderr. 🔹 Descriptions matter more than code. Write docstrings for a human; that is how the AI understands the tool's purpose. 🔹 Validate inputs. Use Pydantic or Zod. Never trust what the AI sends you. 🔹 Restart is mandatory. Claude won't "hot-reload" your config changes. The magic isn't in the protocol itself. It's the realization that you don't need a middleman SaaS for everything anymore. Your AI can now talk directly to your data and infrastructure on your own terms. What tool would you build first? #MCP #AI #Claude #Anthropic #SoftwareEngineering #DeveloperTools #AIAgents #Python #TechLeadership #BuildInPublic
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development