# Simple coding against Gramps db - examples?

**URL:** <https://gramps.discourse.group/t/simple-coding-against-gramps-db-examples/4008>\
**Category:** Development\
**Created:** [August 13, 2023, 8:28pm UTC](https://gramps.discourse.group/t/simple-coding-against-gramps-db-examples/4008 "2023-08-13T20:28:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RMcKenna](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@RMcKenna](https://gramps.discourse.group/u/RMcKenna)\
**Post date:** [August 13, 2023, 8:28pm UTC](https://gramps.discourse.group/t/simple-coding-against-gramps-db-examples/4008/1 "2023-08-13T20:28:08Z")

</div>

I want to create a tree, exactly like that in Gramps, but for a website, using data from Gramps.  
I have already done so, using PHP with a bespoke MYSQL database, which I populated using a lot of tailor made scripts.  
I now realise I should have used:

- Python
- the standard Gramps API for the db access.  
I have never used Python before - the degree of abstraction seems intimidating, but never mind…  
Where can I find some Python examples of code to:
- get a Person
- get their Name
- Get their Parents  
This is only for myself (but I suspect many others would be interested), so I am not interested in ‘fripperies’ like Internationalisation etc etc.

---

<div class="post-metadata">

**Author:** ![Nick-Hall](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/nick-hall/32/95_2.png) [@Nick-Hall](https://gramps.discourse.group/u/Nick-Hall)\
**Post date:** [August 13, 2023, 8:53pm UTC](https://gramps.discourse.group/t/simple-coding-against-gramps-db-examples/4008/2 "2023-08-13T20:53:05Z")

</div>

Have a look at the [add\_to\_tree](https://github.com/gramps-project/gramps/blob/master/gramps/plugins/gramplet/ancestor.py#L160) method in the ancestor gramplet.

Read the [Using database API](https://gramps-project.org/wiki/index.php/Using_database_API) page in the wiki and the API [documentation](https://www.gramps-project.org/docs/).

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [August 14, 2023, 11:43am UTC](https://gramps.discourse.group/t/simple-coding-against-gramps-db-examples/4008/3 "2023-08-14T11:43:46Z")

</div>

When you see a report or gramplet that shows data similar to your interest, you can use them as example code. Plugins tend to be small enough that reverse engineering them is easier than core modules.

But locating that module’s source code can be a challenge in the beginning.

Use the Info button in the [Plugin Manager](https://gramps-project.org/wiki/index.php?title=Gramps_5.1_Wiki_Manual_-_Plugin_Manager) to find the path and filename for the module.

Looking at [add-on filter rules](https://gramps-project.org/wiki/index.php/Rule_expansions) gives even more focused glimpses.

The [SuperTool Addon](https://gramps-project.org/wiki/index.php/Addon:Isotammi_addons#SuperTool) lets you experiment interactively with the database.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/gramps/original/1X/2ac1e712b7adf612e31ca08a55419f4cf37c0158.png) [@system](https://gramps.discourse.group/u/system)\
**Post date:** [September 13, 2023, 11:44am UTC](https://gramps.discourse.group/t/simple-coding-against-gramps-db-examples/4008/4 "2023-09-13T11:44:17Z")

</div>

Closed on September 13, 2023, 11:44am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
