SQLite export clarification?

@Tim reports experiments with the SQLite export creates records of Events where the Event type is a numeric index.

He hasn’t found the table being referenced and the add-on wiki page is kinda thin.

Any suggestions?

1 Like

Maybe needs to make the fixes mentioned here?

1 Like

Maybe we need to reference that Discourse thread on the Wiki page! [done]

Let me know if you want me to post anything here about my SQLite ‘experiments’. Happy for you to take the lead on this

Please do! Me inserting myself in the middle is only a good example of the “Peter Principle

I would just be exposing my technical ignorance and obfuscating issues for the people who actually understand the questions and their answers.

1 Like

The events type are referenced in gramps/gen/lib/eventtype.py

To get the string value corresponding to the index, you must do:

            event_type = [tup for tup in EventType._DATAMAP
                          if tup[0] == index][0]
            evt_id = event_type[0]
            evt_name = event_type[1]

1 Like

See also these enhancement requests:
https://gramps-project.org/bugs/view.php?id=12620
https://gramps-project.org/bugs/view.php?id=12765
https://gramps-project.org/bugs/view.php?id=12766

[done]

1 Like

Thanks. I can use that, cutting and pasting into my jupyter notebook. which is where I’m familiar with using Python, but it illustrates another problem I have, namely not knowing how to access GRAMPS .py files with just an import statement. I can import soundex.py, because it has no relative references in its own import statements, but with pretty well everything else, I get this sort of thing

Is there something I can do?

OK - this is my SQLite ‘experiment’, though for the time being, it’s doing what I need

I exported from GRAMPS to SQLite, saving in the location fld + sqliteExported, then use sqlite3 to connect to it from my jupyter notebook, and after a not too long journey of discovery of the schema of the exported database, produced that long SQL string. Then I read the results into a pandas dataframe, and I’m set to use this to match people who I want to bulk import, but many of whom will already be in my GRAMPS. But I’ll post more about this separately.

If there was a way I could connect to my GRAMPS direct from my notebook, I could eliminate the SQLite exporting step, but the time taken to do this is not a big issue

You need to tell Python how to find the Gramps files. One way is to use PYTHONPATH before the Python interpreter starts. The other way is to make sure that the root directory of the Gramps files is appended to the sys.path in your code. This should be enough to help you web search for additional help.

2 Likes

I thought I’d done that - “appended to the sys.path in your code” - with this

I’m going to ask someone who’s helped me before with this sort of thing to remote into my machine, and see if he can fix it. If he can, it’s going to be really helpful - and fun.

Another option is for me to learn how to develop a gramplet, but I think learning to use Python as a data scientist, as I do, and as a proper developer will take too long. Quite apart from learning the GRAMPS archtecture in sufficient detail, what IDE should I use? How to I test what I write?

In the meantime I can see how I can get on with the particular project I have in mind, with a few manual steps which don’t bother me too much, and then using pandas and such tools developed for the data scientist.

How unusual am I wanting to use GRAMPS this way? I’d be happy to write something about ‘interacting with GRAMPS as a data sceintist’ if the GRAMPS community thought it would be of wider interest

1 Like

very unusual I think, I ended up paying for a external tool to get some interchangeability.
In the end I figured out that I had more feature for hand for my family research with plain markdown notes using FOAM for VSC and Obsidian as my research tool.
With that, I have data views, timelines, map views, network graphs at hand, and can generate any type of report I like and export to most open source and open data format via pandoc.

I can easily create nested events, nested places, hierarchical relations for ownerships, families etc. AND create relations from a document with unstructured data to another or from a list/table object to a Note with just a set of double square brackets. With YAML I can set up aliases for my “Subject Notes”.
I can also use my Zotero library as a source database without any need for double or trippel registration of data.

I still hope for Main/Sub Events and Events for Places in Gramps, as well as being able to use my existing bibliography database as sources and citations in Gramps via CSL-json or another bibliographic open data format…
But I think it is more hope in thinking that Santa will give me a new Honda Transalp 2023 to Christmas.

There are probably hundreds of thousands of people learning Python, maybe R, who’ll be trying to use it like a data scientist. Some of them are going to think about how to use it to handle
data they find doing historical research, where genealogy systems will have a close model of what is needed.

But as John Lennon wrote, you may call me a dreamer😊

Just had my Python developer buddy, David, remote into my machine and try to get this working. This is how far we got

when running a line of code we found in the documentation

So we think we now need first to create an empty GRAMPS database object as described in this page of documentation:

Using database API - Gramps (gramps-project.org)

and then a database object populated with what I have in my GRAMPS

Just as I already have a connection to the data I have in following export to SQLite with the object conExported here

image

I want to have a line starting dbMyGRAMPS = …

I’ll PM you, @prculley asking for an email, so we can have a three way email with David, if that’s OK

1 Like

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