I wonder if there is a way to use PostgreSQL als backend on Windows 10. I already have PostgreSQL running on my Win10/64 machine (and I’m using it quite heavily) and the PostgreSQL add-ons for Gramps (v5.1.6), but I’m running into an error message when I try to define PostgreSQL as the database backend in the settings. The Wiki appears to say that PostgreSQL can only be used on Linux due to missing interface modules on Win, but I’m not sure if my understanding is correct.
The developers put in a lot of work into the AIO (Windows All‐In-One installer package) for the 5.2 cycle.
Support for python module dependencies, changing the dependencies, improving languages support, changing the spellcheck engine, and perhaps most importantly making an automation workflow for building the 64bit AIO … so that is doesn’t take a day of effort to build an AIO each time.
I’m incredibly grateful for all that work contributed by so many developers. It means we can have a new AIO asset posted within hours of the source asset being locked down and posted!
How did you do that? As I said I started out with a running PostgreSQL instance. Following the Wiki description for Linux, I defined a database there, and defined PostgreSQL on localhost:5432 as my default backend in Gramps. No problems with that, but when I then define a new database in Gramps, I get:
29656306: ERROR: grampsapp.py: line 174: Unhandled exception
Traceback (most recent call last):
File "C:\Program Files\GrampsAIO64-5.1.6\gramps\gui\dbman.py", line 986, in __new_db
self._create_new_db(dbid=dbid)
File "C:\Program Files\GrampsAIO64-5.1.6\gramps\gui\dbman.py", line 998, in _create_new_db
new_path, title = self.create_new_db_cli(title, create_db, dbid)
File "C:\Program Files\GrampsAIO64-5.1.6\gramps\cli\clidbman.py", line 301, in create_new_db_cli
newdb = make_database(dbid)
File "C:\Program Files\GrampsAIO64-5.1.6\gramps\gen\db\utils.py", line 85, in make_database
raise Exception("can't load database backend: '%s'" % plugin_id)
Exception: can't load database backend: 'postgresql'
I understand this error message as saying that some Python module is missing which would match @Nick-Hall’s comment that only the latest AIO would contain the necessary python-psycopg2 package.
There are several suggestions for installing psycog2 to Windows on StackOverflow:
Since the Gramps 5.2 AIO installs pip (package installer for Python to help the Addon Manager with prerequisites installation), the process for installing probably going to differ between the Gramps 5.1.x (or earlier) and Gramps 5.2.x versions.
So which of those StackOverflow suggestions (if any) looks appropriate for the different Gramps versions?
Note that there is some chatter about whether adding pip has been a successful experiment. It isn’t part of the macOS installs. So pip might disappear from the 5.3 AIO package.
Thanks for that link but I understand that the initial post is from 2015 and the following answers from 2019 and 2020. So does this really mean that we are talking of an issue that is nearly ten years old and it is still not clear how it can be resolved? I have to confess I’m a bit flabbergasted …
Nope. It means that there are multiple solutions. Just like there are multiple ways to create a tree in Gramps. Each appeals to different user segments.
And that ‘the best’ is probably dependent on the user’s skills level. There is usually a tradeoff between making installation more simple and the work needed to implement the interface and error handling for that simplification.
Finally, there probably haven’t been enough Windows Gramps users that gained enough benefit from PostgreSQL over BSDDB or MySQL to spawn a developer interested in simplifying it.
The Windows AIO uses MSYS2, so you need the corresponding python-psycopg2 package. It is installed as part of v5.2.0 and later.
I suggest that you upgrade. The alternative would be to build your own environment using MSYS2. Using pip to install python-psycopg2 is unlikely to work.
That’s the most interesting point. Some time ago, I gave MySQL a try as database backend and finally switched back to BSDDB since BSDDB appeared a bit faster as MySQL. So your comment appears to say that I should not expect PostgreSQL being much faster than BSDDB or MySQL. At the end of the day this would mean that I should spare myself the work, right?
Just to give you more background information: my database has some 100k person, some 250k events and so on. A search for a person needs some 10 - 15 seconds. So I built a PostgreSQL database from the XML export (the .gramps file) and do all my searches there. The “real” Gramps database is only for editing the data. My hope was of course that the PostgreSQL will be the famous “quantum leap” but …
I’m saying that most Gramps users never even do any kind of comparative benchmarking between database backends.
The plugin for DB backends was new for 5.0 in 2018. SQLite was chosen in 5.1 as a more stable option than BSDDB. And core development focus moved to other things… with the assumption that people interested in other backends could experiment with them as addons.