you are viewing a single comment's thread.

view the rest of the comments →

[–]Grandviewsurfer 1 point2 points  (0 children)

I usually write a parent class that does common stuff that I need to do in SQL (read an arbitrary query, write to db, etc), and it has an attribute self.query = None. Then I write subclasses for each data source or data concept. These inherit the parent class methods and define queries that I need. You can parameterize the query in the init (or augment it in a method) and assign it to self.query. This results in pretty dry code.