Browsed by
Category: Uncategorized

SQLAlchemy + Database Link => ORA-04054

SQLAlchemy + Database Link => ORA-04054

I’ve got this SQLAclhemy table definition that describes a table I’ll be accessing over an Oracle database link: I first created a database link such as this: In SQLAlchemy, access a table column (in a query) via that link would look like tihs I turns out that SQLAlchemy with Oracle database links isn’t a very good match, and easily results in errors such as this: To work around this issue, I created a synonym like this: Now, accessing the table…

Read More Read More

Using the factory pattern to create different emails based on input parameters

Using the factory pattern to create different emails based on input parameters

I wrote a small service that takes an MQ message as input, and based on the contents of the message creates and sends an email. The different types of incoming MQ messages require different types of emails to be created, so I needed a maintainable way to create different emails. For my use case, I found that the factory pattern was a good fit. Consider this code: My business logic code that uses this code then get to be as…

Read More Read More

Spying on Python functions

Spying on Python functions

I was writing test code for a Python project, and needed to spy on the functions of one of the main object’s, called “server”, object instances called “rest_client”. By simply replacing the “rest_client” instance with a mock that passes the actual call to the wrapped object, I’m able to execute the production code of “rest_client” while later on making assertions.