Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

sqlamp is an implementation of Materialized Path for SQLAlchemy.

Project description

sqlamp is an implementation of an efficient algorithm for working with hierarchical data structures – Materialized Path. sqlamp uses (and depends of) SQLAlchemy.

Materialized Path is a way to store (and fetch) a trees in a relational databases. It is the compromise between Nested Sets and Adjacency Relations in respect to simplicity and efficiency. Method was promoted by Vadim Tropashko in his book SQL Design Patterns. Vadim’s description of the method can be read in his article Trees in SQL: Nested Sets and Materialized Path (by Vadim Tropashko).

Implemented features:

  • Setting up with declarative.ext or without it.
  • Saving node roots – if no parent set for node.
  • Saving child nodes – if node has some parent. The whole dirty job of setting values in utility fields is done by sqlamp.
  • Fetching node’s descendants, ancestors and children using the most efficient way available.
  • Autochecking exhaustion of tree size limits (maximum number of children and maximum nesting level) is done during session flush.
  • Rebuilding all trees and any subtree on the basis of Adjacency Relations.
  • Collapsing flat tree returned from query to recursive structure.
  • Node classes may use polymorphic inheritance.

Moving of nodes is not yet implemented.

Known-to-work supported DBMS include sqlite (tested with 3.6.14), MySQL (tested using both MyISAM and InnoDB with server version 5.1.34) and PostgreSQL (tested with 8.3.7), but sqlamp should work with any other DBMS supported by SQLAlchemy.

Project details


Download files

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

Files for sqlamp, version 0.5.1
Filename, size File type Python version Upload date Hashes
Filename, size sqlamp-0.5.1.tar.gz (26.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page