Quick start guide to install and use Akron ORM in your Python projects with practical examples.
Akron is a universal Python ORM that provides a consistent API across SQLite, MySQL, PostgreSQL, and MongoDB. Get started in minutes with this comprehensive guide.
Install Akron using pip. This includes support for SQLite by default:
Collecting akron Installing collected packages: akron Successfully installed akron-1.0.0 Akron 1.0.0 installed successfully akron 1.0.0
Install additional packages for other databases:
Let's create a simple blog application to demonstrate Akron's capabilities:
Database and tables created successfully! Users in database: 2 - alice (alice@example.com) - bob (bob@example.com) Published posts: 2 - Welcome to Akron ORM by user 1 - Database Magic by user 2
Alternatively, use the CLI for quick database operations:
✓ Table 'users' created successfully ✓ Seeded 2 records into 'users' table Query Results: [ {"id": 1, "username": "alice", "email": "alice@example.com", "is_active": true}, {"id": 2, "username": "bob", "email": "bob@example.com", "is_active": true} ] Database Schema: ├── users │ ├── id (int) │ ├── username (str) │ ├── email (str) │ └── is_active (bool)
Akron uses connection URLs to specify database type and location:
Define table schemas using simple type mappings:
Consistent API for Create, Read, Update, Delete across all databases:
Use Pydantic models for automatic validation and type safety:
Connect to MySQL with the same API:
MongoDB works seamlessly with the same API:
Now that you've got the basics, explore advanced features: