Your new code is exactly what I have been running on several production systems, so it looks good to me!
Long story short, `zope.sqlalchemy` had been using the `sqlalchemy` "extensions", which were deprecated in 2012 and are set to be removed (if they haven't been already). see
https://github.com/zopefoundation/zope.sqlalchemy/issues/31The change that caused your issues was due to `zope.sqlalchemy` migrating from the deprecated system to the next. There wasn't a clean way of swapping this out, so their developers opted for a tiny breaking change. For most people, that means changing two lines of code; in some complex projects, 4 lines of code might need to be changed!
Unfortunately, someone posted that answer on StackOverflow that is incorrect and misdirected you – it's not a simple change in class names. I'm sorry that tripped you up.