dodotable
HTML table representation for SQLAlchemy .
SQLAlchemy to <table>
Assume you have an entity called Music. It looks like the below.
class Music(Base):
id = Column(Integer, primary_key=True)
name = Column(Unicode, nullable=False)
The following code renders a sortable <table> consisting of a list of music.
from dodotable.schema import Table, Column
table = Table(
cls=Music,
label='music table',
columns=[
Column(attr='id', label=u'id', order_by='id.desc'),
Column(attr='name', label=u'name'),
],
sqlalchemy_session=session
)
print(table.select(offset=0, limit=10).__html__())
Using with Flask
Flask uses Jinja2 as the template engine. As they mentioned on document[1]_, it is one of strategy that implement __html__ on every class inherit dodotable.schema.Renderable to convert a instance into HTML directly in Jinja2. Re-write the example written before with Flask.
from dodotable.schema import Table, Column
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/musics/', methods=['GET'])
def list_musics():
table = Table(
cls=Music,
label='music table',
columns=[
Column(attr='id', label=u'id',
order_by=request.args.get('order_by')),
Column(attr='name', label=u'name'),
],
sqlalchemy_session=session
)
return render_template(
'list_musics.html',
table=table.select(limit=request.args.get('limit'),
offset=request.args.get('offset'))
)
And list_musics.html which is jinja2 template is look like below.
<html>
<body>
{{ table }}
</body>
</html>
Metadata
Release files for dodotable 0.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dodotable-0.6.1.tar.gz | 14.9 kB | Without provenance | Details |
Release files / dodotable-0.6.1.tar.gz
| Download URL | dodotable-0.6.1.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
731bf5bba7e6ef45ffc3d3ddf683cf701b0fbf9d6be5aaa98cc9c5bf2da5f0b1
|
|
BLAKE2b-256 checksum How to use checksums |
d990e76f3526457bed2cf3ea6270ab809e461a2db9fb32f65e04db4b4da2f18d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for dodotable 0.6.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.