Fresh DB. Clean slate. First ever docker-compose up. And it throws a duplicate table error. How?? There's nothing there. I created nothing. It's literally the first run. ... Turns out, the fastapi app was getting spun up like this > command: gunicorn app.main:app -w 4 .... Looking closely, gunicorn was spinning up 4 workers simultaneously. Every single one of them called create_tables() on boot. Race condition on a clean slate! 🏎️ 💨 Root cause: multi-worker setup + app-level table creation = workers racing each other Fixes: • Dev → switch to uvicorn (single worker, problem gone) • Prod → run an init container or entrypoint script to handle table creation before gunicorn starts • Code-level → make table creation idempotent, handle duplicates gracefully Building a side project is just debugging with extra steps 🥲 #Docker #Python #FastAPI #SideProject #DevLog #BuildingInPublic
Fixing Duplicate Table Error in Docker Compose with FastAPI
More Relevant Posts
-
𝗙𝗿𝗼𝗺 𝗻𝗼𝘁𝗲𝗯𝗼𝗼𝗸 𝘁𝗼 𝘄𝗲𝗯 𝗮𝗽𝗽 - here’s how I turned my Python analysis into an interactive tool with Streamlit ⚡ In my latest Medium article, 𝗧𝘂𝗿𝗻 𝗬𝗼𝘂𝗿 𝗝𝘂𝗽𝘆𝘁𝗲𝗿 𝗡𝗼𝘁𝗲𝗯𝗼𝗼𝗸 𝗶𝗻𝘁𝗼 𝗮𝗻 𝗜𝗻𝘁𝗲𝗿𝗮𝗰𝘁𝗶𝘃𝗲 𝗪𝗲𝗯 𝗔𝗽𝗽 𝘄𝗶𝘁𝗵 𝗦𝘁𝗿𝗲𝗮𝗺𝗹𝗶𝘁, I walk through a step-by-step workflow using my football league simulator as an example, covering: ✅ Organising projects and GitHub repos ✅ Converting notebook code into reusable functions ✅ Managing dependencies with requirements.txt ✅ Keeping API keys secure with .env ✅ Adding interactivity with widgets, styled tables, and download buttons ✅ Deploying your app online with Streamlit 𝗥𝗲𝗮𝗱 𝘁𝗵𝗲 𝗳𝘂𝗹𝗹 𝗴𝘂𝗶𝗱𝗲: https://lnkd.in/gzyPaNYc 𝗧𝗿𝘆 𝘁𝗵𝗲 𝗹𝗶𝘃𝗲 𝘀𝗶𝗺𝘂𝗹𝗮𝘁𝗼𝗿: https://lnkd.in/df_Qe_HE #DataScience #Python #Streamlit #FootballAnalytics
To view or add a comment, sign in
-
-
🌟 New Blog Just Published! 🌟 📌 Boost LLM Apps with 5 Python Decorators for Speed & Savings 🚀 📖 You’re debugging a chatbot that repeats the same user query three times in a row. Each call hits the LLM API, burns $0.03, and adds a full second of latency. By the time the user sees a response, the.... 🔗 Read more: https://lnkd.in/d4jynYyF 🚀✨ #python-decorators #llm-optimization #api-cost-savings
To view or add a comment, sign in
-
-
🐍 Ever wondered what actually happens when a REST API request hits your Flask app? Here's the full lifecycle - broken down into 5 clean steps: 1️⃣ Client sends an HTTP request to your endpoint 2️⃣ Flask router matches the URL via @app.route() 3️⃣ View function reads params & calls the external API 4️⃣ Error handling catches bad input or failed responses 5️⃣ jsonify() serialises your data and sends it back This is literally the backbone of every Flask project I've built - my Weather App, To-Do API, and more. Simple loop. Infinite possibilities. 🚀 Drop a 🔥 if you're also building with Flask! #Python #Flask #RESTAPI #BackendDevelopment #WebDevelopment #PythonDeveloper #LearnToCode #Programming #APIDesign #100DaysOfCode #CodeNewbie #TechStudent #BuildInPublic #FlaskFramework #JSONHandling
To view or add a comment, sign in
-
-
Needed to merge some PDFs for a search warrant assignment. Instead of paying for a third-party tool, I just built my own. 😅 It’s a simple Python desktop app with a dark-themed visual grid for easily rotating, reordering, and combining pages. If you ever need a quick, free way to organize PDFs locally, the code is up here on GitHub: https://lnkd.in/efvffJJ5
To view or add a comment, sign in
-
Recently, I started exploring FastAPI as part of my backend development journey. I began by understanding how to install it using pip and run the application with Uvicorn. I referred to a helpful tutorial on YouTube that clearly explained the setup process and basics of building APIs. Through this, I learned how to: • Install FastAPI and required dependencies • Run the server using Uvicorn • Create basic GET and POST endpoints • Understand automatic API documentation This is just the beginning, but it feels great to take practical steps toward backend development. Looking forward to building more projects and integrating databases next. #FastAPI #Python #BackendDevelopment #LearningJourney
To view or add a comment, sign in
-
🤯 Someone just replaced FastAPI's entire HTTP core with Zig, and the numbers are Jaw-Dropping: 7x faster. A developer just released TurboAPI, a drop-in replacement for FastAPI that runs an HTTP server, routing, JSON parsing, and validation in Zig before Python even wakes up. And the migration? One line: # Before from fastapi import FastAPI; app = FastAPI() # After from turboapi import TurboAPI; app = TurboAPI() That's it. Same routes. Same Pydantic models. Same /docs Still alpha, and WebSocket/HTTP2 are in progress, but the core is real, and those numbers are real. https://lnkd.in/egciNzH5 #Python #Pydev #Developer #FastAPI
To view or add a comment, sign in
-
-
⚡ Building tools that look as good as they code. Most automation scripts are functional but eyesores. I wanted to change that. Just wrapped up a YouTube Thumbnail Grabber built with Python, but with a twist: I focused heavily on the UI/UX, implementing a custom "Jetstorm Theme" to make the utility feel like a premium app. The Secret Sauce: ✨ Dynamic UI: Automated Canvas Drawing (Grid + Stars) for a retro-tech vibe. 📐 Custom Geometry: Moving beyond basic Tkinter grids for a modern layout. 🖼️ High-Res Processing: Leveraging Pillow for clean image handling. Stack: Python | Tkinter | Requests | PIL It’s simple, efficient, and aesthetic. 💻 Source Code: [https://lnkd.in/dGUCm928] #Python #SoftwareDevelopment #OpenSource #GUI #Coding #LaxmiSanas
To view or add a comment, sign in
-
switching from pip to uv genuinely impressed me. I’ve been using pip for years. It’s stable, trusted, and part of almost every Python workflow. No complaints at all. But recently I tried uv out of curiosity. And the speed difference? Very noticeable. Dependencies install insanely fast. Environment setup feels almost instant. Everything just feels smoother and more responsive. One big reason: uv is built with Rust. That means it’s designed for performance, safety, and robustness from the ground up. You can actually feel that difference when working on bigger projects or rebuilding environments multiple times a day. pip is still solid. But uv feels modern. Fast. Efficient. Built for today’s development speed. Sometimes productivity isn’t about writing better code. #Python #Rust #DeveloperTools #Performance #SoftwareDevelopment #Productivity #ProgrammingLife
To view or add a comment, sign in
-
-
Learn how to build an AI web app with Python and Flask. Discover the step-by-step guide to creating an AI-powered web app without extensive coding knowledge. Read the full article 👉 https://lnkd.in/dVZhQphP #PythonFramework #ArtificialIntelligence #FlaskWebApp #AIpoweredWebApps #DevOpsStrategy #TechLab Code. Learn. Build. — TechLab by Neeraj
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