Metadata-Version: 2.1
Name: pythonish-ql
Version: 0.0.6
Summary: Pythonish query language for dictionary-like data
Home-page: https://github.com/dsblank/pythonish-ql
Author: Doug Blank
License: MIT License
Platform: Linux
Platform: Mac OS X
Platform: Windows
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: gramps

# pythonish-ql

A Pythonish Query Language, for the [Gramps Project](https://gramps-project.org/) and other objects.

This project is designed to be a drop-in replacement for https://github.com/DavidMStraub/gramps-ql

Rather than having to build, and learn, a new query language, the idea
is to build on top of Python, the native language of the Gramps Project.
And, rather than having to convert the Gramps raw data into objects, then dicts, and
then back again to objects (when needed), this query system can operate directly
on the objects.

Originally, I had extended the syntax of language Python and therefore called this
`Pythonish`. However, currently, the language is pure Python without any change in
syntax.

Each object can be identified by its type, eg `person`, `note`, `family`, etc.

Examples:

Find the person with a particular gramps_id:

```python
person.gramps_id == 'person001'
```

Find all of the people with notes:

```python
person.get_note_list()
```
Find all of the people with notes that mention 'vote':

```python
any([('vote' in str(get_note(handle).text)) for handle in person.get_note_list()])
```

## Usage

If you don't know what the type is, you can use `obj`, like:

```python
"23" in obj.gramps_id
```
You can use standard dot notation to reference any object. Refer to [Gramps Primary Objects](https://www.gramps-project.org/wiki/index.php/Using_database_API#Primary_Objects) for the structure of Gramps objects.

You can also use the `SimpleAccess` methods that make access to some data much easier. The [SimpleAccess](https://gramps-project.org/docs/simple.html#module-gramps.gen.simple._simpleaccess) is available as `sa`, as shown below.

Select all of the people that have are married to a person named "Donna":

```python
sa.first_name(sa.spouse(person)) == "Donna"
```
