Flask integration for sqlorm
Project description
Flask-SQLORM
Flask integration for sqlorm
Setup
Install:
$ pip install flask-sqlorm
Setup:
from flask import Flask
from flask_sqlorm import FlaskSQLORM
app = Flask()
db = FlaskSQLORM(app, "sqlite://:memory:")
Usage
All exports from the sqlorm package are available from the extension instance.
Define some models:
class Task(db.Model):
id: db.PrimaryKey[int]
title: str
done: bool = db.Column(default=False)
Start a transaction using the db object:
with db:
Task.create(title="first task")
In views, the current session is available using db.session
Configuration
Configure the sqlorm engine using the extension's constructor or init_app(). Configuration of the engine is performed using the URI method.
Additional engine parameters can be provided as keyword arguments.
Configuration can also be provided via the app config under the SQLORM_ namespace. Use SQLORM_URI to define the database URI.
Additional utilities provided by Flask-SQLORM
Model classes have the additional methods:
find_one_or_404: same asfind_onebut throw a 404 when no results are returnedget_or_404: same asgetbut throw a 404 when no results are returned
Managing the schema
Some CLI commands are available under the db command group. Check out flask db --help for a list of subcommands.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flask_sqlorm-0.1.1.tar.gz.
File metadata
- Download URL: flask_sqlorm-0.1.1.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-40-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13ecb4eed6eff3bcb13e63b8e772129879570e929155d87b3ca5ef85edfafcb2
|
|
| MD5 |
c9a33dd05d6981b4a04d60e341a2154f
|
|
| BLAKE2b-256 |
f19bf03525ee27bd1d26933a127c66d22766a87ca1653838fbee63cc3fbf1866
|
File details
Details for the file flask_sqlorm-0.1.1-py3-none-any.whl.
File metadata
- Download URL: flask_sqlorm-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-40-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebf01e0215bb8adf2bdc6e71bca71e9d9dddfbf3b8031a257aa0ddbaba2a7cf3
|
|
| MD5 |
201c3be31ecb6e4b40e81e6fa4233167
|
|
| BLAKE2b-256 |
34f6fec8e512a67b5111867a520df594a3e19333ef8e030de2d1a282caf4fe93
|