This environment gives you a Python 3.12 setup preconfigured for database work with SQLAlchemy, Alembic, and all the build dependencies you need to connect to PostgreSQL without the usual headaches.
- Ready-to-use SQLAlchemy and Alembic setup
- All PostgreSQL driver dependencies pre-installed
- Smart venv management that doesn't get in your way
- Cross-platform support with zero configuration
- Compiler toolchain included for native extensions
python312- Latest current-stable Python 3.12 package; useflox editto change versionsSQLAlchemy- The Python SQL toolkit and ORMAlembic- Database migration tool that doesn't suckgcc+zlib- Build dependencies for psycopg2pip- Latest Python package managergum- Clean terminal UI for environmentsbat- Used forreadmefunction
- Flox installed
- That's it
git clone https://github.com/youruser/sqlalchemy-env && cd sqlalchemy-env
flox activate# Create a new virtual environment
mkvenv
# Activate any venv in the current directory tree
aktivate
# Exit the current virtual environment
qwit# Install dependencies from requirements.txt
pist
# Install from a different requirements file
pist dev-requirements.txt- No more psycopg2 build errors - All required libraries are included
- No more "I can't find my venv" - The
aktivatecommand scans the directory tree - No more dependency conflicts - Isolated Python environment
- No more migrations headaches - Alembic is ready to use
-
psycopg2 installation issues:
- If you still have issues, try
pip install psycopg2-binaryinstead - Make sure you've activated a venv first with
aktivate
- If you still have issues, try
-
Virtual environment problems:
- Try
rm -rf .venvand create a fresh one withmkvenv - Check that Python 3.12 is correctly installed in your Flox environment
- Try
-
SQLAlchemy connection issues:
- Verify PostgreSQL is running and accessible
- Check connection strings for typos
- Make sure any required database roles exist
Works on:
- macOS (ARM/Intel)
- Linux (ARM/x86)
- Use SQLAlchemy's connection pooling for better performance
- Set up Alembic migrations early in your project
- Consider using SQLAlchemy 2.0-style queries for future compatibility
- If working with large databases, enable SQLAlchemy's query profiling
Flox combines package and environment management, building on Nix. It gives you Nix with a git-like syntax and an intuitive UX:
- Declarative environments. Software packages, variables, services, etc. are defined in simple, human-readable TOML format;
- Content-addressed storage. Multiple versions of packages with conflicting dependencies can coexist in the same environment;
- Reproducibility. The same environment can be reused across development, CI, and production;
- Deterministic builds. The same inputs always produce identical outputs for a given architecture, regardless of when or where builds occur;
- World's largest collection of packages. Access to over 150,000 packages—and millions of package-version combinations—from Nixpkgs.