Skip to main content

A Python database interface for eXist-db

Project description

snakesist Documentation Status

snakesist is a Python database interface for eXist-db. It supports basic CRUD operations and uses delb for representing the yielded resources.

pip install snakesist

snakesist allows you to access individual documents from the database using a delb.Document object, either by simply passing a URL

>>> from delb import Document

>>> manifest = Document("existdb://admin:@localhost:8080/exist/db/manifestos/dada_manifest.xml")
>>> [header.full_text for header in manifest.xpath("//head")]
["Hugo Ball", "Das erste dadaistische Manifest"]

or by passing a relative path to the document along with a database client which you can subsequently reuse

>>> from snakesist import ExistClient

>>> my_local_db = ExistClient(host="localhost", port=8080, user="admin", password="", root_collection="/db/manifests")
>>> dada_manifest = Document("dada_manifest.xml", existdb_client=my_local_db)
>>> [header.full_text for header in dada_manifest.xpath("//head")]
["Hugo Ball", "Das erste dadaistische Manifest"]
>>> communist_manifest = Document("communist_manifest.xml", existdb_client=my_local_db)
>>> communist_manifest.xpath("//head").first.full_text
"Manifest der Kommunistischen Partei"

and not only for accessing individual documents, but also for querying data across multiple documents

>>> all_headers = my_local_db.xpath("//*:head")
>>> [header.node.full_text for header in all_headers]
["Hugo Ball", "Das erste dadaistische Manifest", "Manifest der Kommunistischen Partei", "I. Bourgeois und Proletarier.", "II. Proletarier und Kommunisten", "III. Sozialistische und kommunistische Literatur", "IV. Stellung der Kommunisten zu den verschiedenen oppositionellen Parteien"]

You can of course also modify and store documents back into the database or create new ones and store them.

Your eXist instance

snakesist leverages the eXist RESTful API for database queries. This means that allowing database queries using the _query parameter of the RESTful API is a requirement in the used eXist-db backend. eXist allows this by default, so if you haven’t configured your instance otherwise, don’t worry about it.

Please note that snakesist is tested with eXist 4.7.1 and is not compatible yet with version 5. The bug preventing snakesist to be compatible with the newest major eXist version will be fixed with the release of eXist 5.3.0.

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 snakesist, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size snakesist-0.2.0-py3-none-any.whl (11.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size snakesist-0.2.0.tar.gz (11.4 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