July 22, 2024

Recoding my micromount database in Python

These are notes for myself primarily.

At one time, when I was young and foolish, I worked up my micromount database using Ruby on Rails. That was a disaster due to the instability and terrible management of the Rails project. I converted it to a plain Ruby program. This meant it would no longer work on the web, but that mattered not at all. But Ruby is only so much better due to sloppy work by the Ruby team and endless version changes and incompatibilites.

So in July of 2024, I threw in the towel on Ruby and gem confusion and began recoding the whole thing in Python. These are my notes as that project unfolds. Nicely enough, the actual data is in a sqlite3 database and could care less what language is used to access it. I could use Java or Haskell no doubt, in lieu of Python. The benefit of Python is that despite its shortcomings, it is at least mainstream and in my experience much more stable than Ruby.

I want to make some comments after about a week into the project. There are some things I like about Python over Ruby besides stability. In ruby you can write subroutine calls without parenthesis. I always (for no good reason sometimes) aim to be succint, so I adopted this -- but it makes code hard to read after several years. It is nice to see parenthesis to clue you in that it is a method or function call.

I like wxPython. Documentation for Ruby-GTK was always nearly non-existant, so you had to rely on the C API documents -- which was not all that bad, but the situation with wxWidgets is much better. I certainly like wxPython better than TkInter.

I made one major strategic change with the python version -- namely I read all of the database records into memory and perform almost all manipulations on the python data structure rather than using SQL to perform searches and such. I have yet to have any regrets about this. Maybe if the database was truly immense this would be an issue, but it matters not at all with 1300 records, and I would be very much surprised if it matters with 10,000 to 20,000 on a modern machine.


Feedback? Questions? Drop me a line!

Tom's Mineralogy Info / tom@mmto.org