Python/SQLite best practices

Jonathan Moules jonathan-lists at lightpear.com
Tue Aug 6 05:14:03 EDT 2019


>> * To be reliably INSERTed Byte data should be first converted to 
>> sqlite3.Binary(my_data) explicitly
>
> Interesting. Is that Python 2 specific, or also in Python 3. Because 
> the latter would surprise me (not saying it isn't the case).
Only tried on Python 3. I'm inserting raw byte versions of web-pages. I 
forget the exact details but I have a comment in my code to the above 
effect so I must have ended up bashing my head against it at some point. 
A zip/lzma compressed byte output doesn't need this wrapper though.

> On a UNIX system the command "lsof -p pid-of-running-python-process" 
> should show the path of the sqlite library that is linked to the 
> Python executable, which should let you learn this.
>
Thanks, I'll have to add that to the collection. I know when I was 
googling around for it on *nix I came across a bunch of different 
answers none of which seemed to work. Windows is a simple matter of 
replacing the right DLL (though again not really documented). I still 
have no idea how to do it on *nix but that's another thread.




More information about the Python-list mailing list