[egenix-users] Zope, MySQL, UTF-8 FIXED(?)

Jan Stiller Jan.Stiller at hagen-partner.de
Mon Feb 14 17:49:18 CET 2005


Jan Stiller wrote:

> Charlie Clark wrote:
>
>>On 2005-02-14 at 16:37:27 [+0100], Jan Stiller 
>><Jan.Stiller at hagen-partner.de> wrote:
>>  
>>
>>>Hi Charlie
>>>
>>>asking for help obviously liberated my brain ;o)
>>>
>>>1.
>>>This
>>>
>>>SET CHARACTER SET utf8
>>><dtml-var sql_delimiter>
>>>update test
>>>set textfeld = <dtml-sqlvar text type=string>
>>>where tid = 1
>>>
>>>seems to work... and Zope (or whoever) seems to remember this between
>>>different calls (I commented set char... out).
>>>
>>>Is there any 'official' place to set the character set?
>>>
>>>
>>>2.
>>>Do you have a small example for an external method? (I need some batch
>>>processing too)
>>>    
>>>
>>
>>The external method just receives an mxODBCZopeDA connection object and 
>>calls its .execute(code, (paras)) method as if it were written in Python. I 
>>posted an example on the Zope-DB list last year.
>>
>>ah here it is:
>>
>>3) Use an external Method. This has the advantage of being much finer 
>>grained 
>>conrtol than allowing all PythonScripts to do something but done properly 
>>is 
>>nearly as flexible.
>>
>>Create a file in ~/Extensions say ODBC_SQL.py
>>
>>This is essentially needs only one function:
>>
>>def callSQL(connectionObject, statement):
>>	conn = connectionObject.database_connection()
>>	return conn.execute(statement)
>>
>>Create an external method say SQL which points to callSQL in ODBC_SQL
>>
>>You can then call this method from any PythonScript and simply pass it the 
>>connection and statement you want to execute.
>>
>>In your case the PythonScript needs only to be modified slightly, depending 
>>on what you want to.
>>
>>statement = """select [Building ID] from [Buildings]
>> where [Building Name] = ?""", building)[1]
>>columns, results = context.SQL(container.crc_db, statement)
>>
>>Hope that helps
>>
>>Charlie
>>  
>>
> Thanks indeed
>
> We have many many ZSQLs and we wouldn't like to rewrite all their 
> callees - your (btw fine) product surely has one single place, where 
> connections are made. Is it possible to make a 'SET CHARACTER 
> SET'-call right after the creation of the connection or do I have to 
> repeat this every time?
>
> tia
> Jan
>
>------------------------------------------------------------------------
>
>
>_______________________________________________________________________
>eGenix.com User Mailing List                     http://www.egenix.com/
>http://lists.egenix.com/mailman/listinfo/egenix-users
>  
>

Maybe I just found the answer ('asking for help obviously...' ;o):

DSN=myodbc;UID=root;
PWD=pwd;
STMT=SET CHARACTER SET utf8

you can add a statement to your connection string and everything seems 
to work fine...

I will test this assumption with our big application.

Thanks Charlie

ciao
Jan


p.s. If we buy your product, do we get the opportunity to program some 
calls like the one mentioned above?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /mailman-archives/egenix-users/attachments/20050214/76ed0243/attachment-0139.htm


More information about the egenix-users mailing list