Take the 2-minute tour ×
Genealogy & Family History Stack Exchange is a question and answer site for expert genealogists and people interested in genealogy or family history. It's 100% free, no registration required.

One of the several places I have my genealogy data is in gramps (see http://gramps-project.org/), an open source program written in python (a very easy to learn computer language for those interested). I have written several programs of my own playing with my data, starting with either gedcom or csv exported from either gramps or one of the other programs I use (eg myheritage). Gramps uses a more pythonic data model (eg people are python objects - see http://www.gramps-project.org/docs/gen/gen_lib.html#module-gen.lib.person). Is there a file somewhere that has this data in it then I can just copy and use in other programs? Or is there an easy way to extract the data in it's native python format?

I have tried to figure this out by reading the source but I don't understand the overall design well enough to find the hook I'm looking for. I'm hoping someone more familiar with gramps can point me in the right direction.

I've looked at the db api, but did not understand well enough so I (erroneously now that I've read the answers to this questions) thought that it would not be applicable.

share|improve this question
2  
+1 I did not know that Gramps was written in Python - it just became a lot more interesting :-) –  PolyGeo Oct 16 '12 at 0:23
    
@PolyGeo - It's been great for me, except for performance on large-ish data sets. (E.g. full-database analysis on 10s of thousands of individuals.) :( –  bstpierre Oct 16 '12 at 12:20
1  
@bstpierre - Have you seen the Gramps wiki page called "Tips for large databases" gramps-project.org/wiki/… –  Sam Oct 18 '12 at 3:42

3 Answers 3

up vote 5 down vote accepted

This simple program will print out the internal representation for each person in your database. Doing something interesting is left as an exercise for the reader...

#!/usr/bin/python

import DbState
import gen.db.read as read
from gen.db import DbBsddb
from gen.lib import Person

def callback(value):
    pass

dbclass = DbBsddb
dbstate = DbState.DbState()
dbstate.change_database(dbclass())
dbstate.db.load('/home/brian/.gramps/grampsdb/4fcdfec9/', callback, 'r')

for handle, person in dbstate.db.get_person_cursor():
    p = Person(person)
    name = p.get_primary_name()
    print name.get_name()

See also /usr/share/gramps/cli/grampscli.py in your distribution, which is where I looked when I cobbled together the code above.

share|improve this answer
2  
@Duncan: I just revised it to show the creation of a Person object from the raw data in the person cursor. –  bstpierre Oct 16 '12 at 13:27

Surely, you do need not be reminded that GEDCOM is useful, that if your chart app reads GEDCOM, it is not restricted to Gramps. You are specifically interested in getting Gramps data in its Python format, for easy processing by your own Python apps.

Gramps is Open Source, so the quick & easy answer is the RTSL: Read the Source, Luke. Once you've figured out how Gramps does it, you may be able to adapt that code to your use.

There are a few things worth pointing out in addition to that obvious advice:

  1. Gramps supports plug-ins. Turning your app into a Gramps plug-in might well be the easiest way to get direct access to the internal data model.
  2. Gramps features fan charts already. Looking through that code may be particularly helpful in figuring out how to do it the Gramps way.
  3. Others Gramps developers had to learn about how it all works too. Contacting them may help you get up to speed.
  4. ...but you should probably start by reading the Gramps Developer Portal section of the Gramps Wiki, particularly Using database API. There is helpful information about the relation between Python objects and the database there.

On a final note, Gramps blog posts have revealed that Gramps 4.0 will include a much-improved fan chart.

share|improve this answer
    
Oops. I guess I was wrong. As shown in the other answer, it is the db api that pulls them in native format. I apologize. –  Duncan Oct 16 '12 at 13:23
    
Yes, I noticed that, so thought I would direct you to the database API documentation, which you seemed to have missed. Don't you just love getting a correct answer to a wrong question? ;-) –  TamuraJones Oct 16 '12 at 14:05
    
Point#4 answers the question. Why obscure that answer with all the other stuff? –  Tom Morris Oct 16 '12 at 15:09
1  
@TomMorris, point 4 answers part of the question. –  TamuraJones Oct 16 '12 at 16:26

GRAMPS uses the Berkeley database as its native format.

Over at Stack Overflow was the question Examining Berkeley DB files from the CLI from someone who wanted to view the contents without having to write scripts.

A couple of answers included the db-utils package and the db_hotbackup utility.

share|improve this answer
1  
This would be a hard way to go, because there is no schema, in database parlance. In other words, you could get at the data, but you wouldn't know what it was. The Python interface decodes that for you. –  Doug Blank Jan 30 '13 at 1:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.