>
> > sqlobject.dburi="firebird://user:password@localhost
> > :3050/pathToTheDatabase/automaty.fdb?charset=utf8"
>
>
>
Finally, it looks I was focused on the column values to much, when hunting
mentioned UnicodeDecodeError.
You can find the solution here:
The *names* list generated in:
names = [self.sqlmeta.columns[v[0]].dbName for v in setters]
(_SO_finishCreate method in main module)
contains unicode type string elements (column names) for the columns, that
are not manually defined in the model.
because of that:
return ("INSERT INTO %s (%s) VALUES (%s)" %
(table, ', '.join(names),
', '.join([self.sqlrepr(v) for v in values])))
throws:
UnicodeDecodeError "'ascii' codec can't decode byte 0xc4 in position 95:
ordinal not in range(128)"
Yes, it looks strange, but:
1. unicode type string is generated from the ', '.join(names), when
there is at least one element in the list containing unicode type string
2. an unicode type string is generated from the "INSERT INTO %s (%s)
VALUES (%s)" when the first part of the string formating is executed
3. when there is an encoded string in the values, it is not possible to
execute the second part of the string formating and an exception ocures
to understand it, try to experiment with the following code:
table = "pokladna"
myJoinedNames = u'id, autorizovano, vydal_osoby_id, mena_id,
vydal_automaty_id, platny_zaznam, t_stamp, castka_czk, prijal_osoby_id,
vycetky_od_automatu_id, prodejni_mista_id, prijal_automaty_id,
pohyby_zbozi_id, castka, id_hash_vydal, poznamka, ucel_id, id_hash_prijal'
myJoinedValues = "3219, 0, 3, 1, NULL, 1, '2012-02-26 00:41:31', 2000.0,
16, NULL, NULL, NULL, NULL, 2000.0, 3, '\xc4\x9b\xc5\xa1\xc4\x8d\xc5\x99',
3, NULL"
print "INSERT INTO %s (%s) VALUES (%s)" % (table, myJoinedNames,
myJoinedValues)
As an "short and dirty" solution I have defined all columns in the affected
table manually.
I am not sure, if above mentioned is not caused because of I have
rewritten columnsFromSchema and guessClass methods in the
firebirdconnection module.
I am pretty sure, Oleg will come with an other, elegant solution for this
problem.
Regards
Petr
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss