All of mine use
Code:
with closing(sqlite.connect(self.device_database_path())) as connection:
connection.text_factory = lambda x: unicode(x, "utf-8", "ignore")
connection.row_factory = sqlite.Row
"self.device_database_path()" returns the full path to the database.
I don't use the row_factory everywhere. The code I was working with initially didn't and just used numeric indices into the results. I'm now using a mix depending on when I wrote the code and how many columns are in the result. If I have to take my shoes of to count, I use the names