Quantcast
Channel: RasadaCrea rss feeds aggregator
Viewing all articles
Browse latest Browse all 176

Tuples in the Pythonic, TTM-inspired interface to PostgreSQL

$
0
0
The Third Manifesto formally describes tuple types (RM prescription 6), tuple values (prescription 9), tuple variables (prescription 12) as well as other tuple-related elements. As mentioned in the previous post , a tuple value is a set of ordered triples each consisting of attribute name, type and value. Class Tuple of the TTM-inspired interface to PostgreSQL models TTM tuples as Python lists of TTM Attribute objects. Lists were used rather than sets because for many practical purposes the order of the attributes is useful (or has "meaning"), e.g., the first attribute listed is most often –even in purist relational theory presentations– the primary key or part of the primary key. The interface stores the Tuple heading as a (Python) n-tuple of name-type tuples, in the "internal use" _heading attribute. The n-tuple was chosen over a list due to its immutability. The interface also sets each Attribute as a Python attribute of the Tuple object. Thus, if you define a Tuple variable as follows: film = Tuple(     Attribute('id', int, sysdefault=True),     Attribute('title'),     Attribute('release_year', int)]) You can then assign or access an Attribute using simple Python syntax: film.title = "Seven Samurai" if film.year == 1954: .. cntd

Viewing all articles
Browse latest Browse all 176

Trending Articles