I need to write some static .sql files (just as an explanation, it is startup code for Django). Some of the strings are non-ascii. I'm stumped about how to get utf-8 instead of latin-1 in the file.
I'm generating the .sql as strings, without a connection. I found a prior message on this list that suggested what to do (1) and came up with this routine.
adapted = psycopg2.extensions.adapt(s)
But it encodes in latin-1. I understand from the docs that I need to get a connection and set the .encoding attribute, but I can't see how to get a connection instance without a db handy. For instance,
>>> conn = psycopg2.connect(database = None)
I expect that I am asking a dopey question (I'm not very sure what I am doing) but I'd appreciate a pointer even if it makes me feel dumb.
psycopg by date
|Next:||From: Daniele Varrazzo||Date: 2013-07-21 20:08:20|
|Subject: Re: Getting adaped output from unicode text, without a connection|
|Previous:||From: Daniele Varrazzo||Date: 2013-07-21 17:35:20|
|Subject: Re: Connection failures when using green|