Initialize database connections with the Akron class constructor for SQLite, MySQL, PostgreSQL, and MongoDB.
The Akron constructor is your entry point to any database. It accepts a connection URL string and automatically selects the appropriate driver based on the URL scheme.
Akron(db_url: str = "sqlite:///akron.db")
Type: str
Default: "sqlite:///akron.db"
Database connection URL. The scheme determines which driver to use:
sqlite://
- SQLite databasemysql://
- MySQL databasepostgres://
- PostgreSQL databasemongodb://
- MongoDB databaseType: Akron
An Akron instance configured with the appropriate database driver ready for operations.
sqlite:///path/to/database.db
- File databasesqlite:///:memory:
- In-memory databasesqlite:///./relative/path.db
- Relative pathmysql://user:password@host:port/database
- Standard formatmysql://user@host/database
- No passwordmysql://user:password@host/database?option=value
- With optionspostgres://user:password@host:port/database
- Standard formatpostgresql://user:password@host:port/database
- Alternative schemepostgres://user@host/database?sslmode=require
- With SSLmongodb://host:port/database
- Simple connectionmongodb://user:password@host:port/database
- With authenticationmongodb://host1:port1,host2:port2/database
- Replica setStore database credentials in environment variables for security:
Akron automatically handles connection pooling for database drivers that support it, ensuring efficient resource usage in production applications.