SQLAlchemy integration for FastHTML
Project description
fasthtml-sqlalchemy
Integración de SqlAlchemy con el framework fastHTML
Instalación
pip install fasthtml-sqlalchemy
Ejemplo de uso:
from fasthtml import FastHTML
from fasthtml_sqlalchemy import SQLAlchemy, BaseModel
app = FastHTML()
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db'
db = SQLAlchemy(app)
class User(BaseModel):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True, nullable=False)
db.create_all()
@app.route("/")
def get():
users = db.session.query(User).all()
return str(users)
@app.route("/add/<username>")
def add(username):
user = User(username=username)
user.save()
return f"User {username} added!"
if __name__ == "__main__":
app.serve()
y la ayuda sigue por aquà ...
Project details
Release history Release notifications | RSS feed
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 fasthtml_sqlalchemy-0.1.0.tar.gz.
File metadata
- Download URL: fasthtml_sqlalchemy-0.1.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f17b99fb6bdb2d023659f86c01e9fbad4fcacae2199910c31f3d15768be11857
|
|
| MD5 |
9c8d63feb952ff24b6106dea9973a8b1
|
|
| BLAKE2b-256 |
d5b5368d82aa01869a279a16a0ae3605d5f2981b3b80138c24d3fe80c9bb3ae1
|
File details
Details for the file fasthtml_sqlalchemy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fasthtml_sqlalchemy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10a6c550ab538c28ce56f1ccdd889986c1e911bbd343d1d515db2aab269b6653
|
|
| MD5 |
cecbbfcb8d0a772a7d6b4069756fcbbf
|
|
| BLAKE2b-256 |
cd3a68795c1bb8cee022bea16b672bf0784452115c9f343d223fd2386d048e92
|