Files
sqlalchemy/examples/elementtree/__init__.py
T
Vraj Mohan 0717ce9d1d Reinstate elementtree example
Partially fixes sqlalchemy/sqlalchemy#4426.

Closes: #4441
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4441
Pull-request-sha: ed90f3b77c

Change-Id: Ic32e5d8020073da055b12a6aeb61e698a97dc504
2019-01-16 20:21:48 -05:00

26 lines
824 B
Python

"""
Illustrates three strategies for persisting and querying XML
documents as represented by ElementTree in a relational
database. The techniques do not apply any mappings to the
ElementTree objects directly, so are compatible with the
native cElementTree as well as lxml, and can be adapted to
suit any kind of DOM representation system. Querying along
xpath-like strings is illustrated as well.
E.g.::
# parse an XML file and persist in the database
doc = ElementTree.parse("test.xml")
session.add(Document(file, doc))
session.commit()
# locate documents with a certain path/attribute structure
for document in find_document('/somefile/header/field2[@attr=foo]'):
# dump the XML
print document
.. autosource::
:files: pickle_type.py, adjacency_list.py, optimized_al.py
"""