Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Extended SQLAlchemy declarative_base class

Project Description

This package provides an extended Base class for your SQLAlchemy classes.
What this class proposes:
* the __tablename__ to create/use for the class is automatically defined by class.__name__.lower().
* it adds a property pk_id which returns the value of the primary key for the object.
* it attaches a query object to the class which is a shortcut to session.query(class).
* Function which returns all the DB entry in a HTML table
* Function to edit/add new entry as a HTML form

Example of usage::

import sqlalchemy as sa
from sqlalchemy.orm import (
from zope.sqlalchemy import ZopeTransactionExtension
from sqla_declarative import extended_declarative_base

session = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
Base = extended_declarative_base(

class Test1(Base):
id = sa.Column(sa.Integer, primary_key=True)
name = sa.Column(sa.String(50))

bob = Test1(name='Bob')

# pk_id detects automatically the primary key and returns it value
bob.pk_id == 1
# Easy querying. For example: == bob

# To see all the existing entry as HTML

# To add/update a new entry as HTML
widget = Test1.edit_form()
Release History

Release History

This version
History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
sqla_declarative-0.2.tar.gz (3.8 kB) Copy SHA256 Checksum SHA256 Source Jan 10, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting