Rithik
Rithik
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
ok it worked now 😭
27 replies
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
imma switch over to a normal vps at this point
27 replies
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
😭
27 replies
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
its just not happening man what the hell
27 replies
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
it is valid, works locally. anyways, i will try figure out on my own
27 replies
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
# Database setup
SQLALCHEMY_DATABASE_URL="sqlite:////app/data/database.db"
engine = create_engine(SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False})
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
# Database setup
SQLALCHEMY_DATABASE_URL="sqlite:////app/data/database.db"
engine = create_engine(SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False})
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
27 replies
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
same error sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to open database file
27 replies
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
thats not working
27 replies
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
what should be sqlite uri?
27 replies
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
volume mount path is - /app/data
27 replies
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
So Im confused now
27 replies
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
the time it was working, it wasnt persisting on redeploys 😔
27 replies
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
created a volume at /app/data
27 replies
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
# Database setup
SQLALCHEMY_DATABASE_URL = "sqlite:////app/data/database.db"
# Database setup
SQLALCHEMY_DATABASE_URL = "sqlite:////app/data/database.db"
27 replies
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
dockerfile
27 replies
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
# Use an official Python runtime as the base image
FROM python:3.9-slim

# Set the working directory in the container
WORKDIR /app

# Copy the requirements file into the container
COPY requirements.txt .

# Install the required packages
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code
COPY . .

# Create a non-root user and switch to it
RUN adduser --disabled-password --gecos '' appuser

# Create a directory for the database and set permissions
RUN mkdir -p /app/data && chown -R appuser:appuser /app/data

# Switch to the non-root user
USER appuser

# Make sure the static directory exists
RUN mkdir -p static

# Expose the port the app runs on
EXPOSE 8000

# Set the database path to the persisted volume
ENV DATABASE_URL=sqlite:////app/data/database.db

# Command to run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
# Use an official Python runtime as the base image
FROM python:3.9-slim

# Set the working directory in the container
WORKDIR /app

# Copy the requirements file into the container
COPY requirements.txt .

# Install the required packages
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code
COPY . .

# Create a non-root user and switch to it
RUN adduser --disabled-password --gecos '' appuser

# Create a directory for the database and set permissions
RUN mkdir -p /app/data && chown -R appuser:appuser /app/data

# Switch to the non-root user
USER appuser

# Make sure the static directory exists
RUN mkdir -p static

# Expose the port the app runs on
EXPOSE 8000

# Set the database path to the persisted volume
ENV DATABASE_URL=sqlite:////app/data/database.db

# Command to run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
27 replies
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
I set it up from a template, with volume it wasnt working either sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to open database file
27 replies
RRailway
Created by Rithik on 9/6/2024 in #✋|help
How do I connect my python app to sqlite?
7418d6aa-d7a2-45b1-962f-bfd0f0773a06
27 replies
RRailway
Created by Rithik on 2/4/2024 in #✋|help
trying to host a static website with nginx.
i figured it out, this can be closed now.
7 replies
RRailway
Created by Rithik on 2/4/2024 in #✋|help
trying to host a static website with nginx.
i will try and update
7 replies