Re: [gnome-db] INSERT statement with binary data





2009/1/20 Johannes Schmid <jhs jsschmid de>
Hi!

I am trying to fix a bug in glom where it tries to insert binary data (a
png image) using an INSERT statement. SqlParser reports that the
statement is malformed but I couldn't figure out how to fix that. The
statement is basically:

INSERT INTO "contacts" ("contact_id", "name_first", "name_middle",
"name_last", "name_title", "address_street", "address_town",
"address_state", "address_country", "address_postcode", "date_of_birth",
"comments", "name_full", "picture", "email", "website", "tel_home",
"tel_work", "tel_mobile", "tel_fax") VALUES
(0,'Murray','','Cumming','Mr','Falschstrasse
123','Munich','Bavaria','Germany','D-80798','1973-05-11','','Murray
Cumming', '<no a lot of binary data follows>',
'','www.murrayc.com','','','','')


The binary data looks about like this: \\362\\377\\001NIU\\225\\016\\376
\\034\\350\\000\\000\\000\\000IEND\\256B`\\202 (just an example.

How does this data need to be encoded so that GdaSqlParser is happy with
it?

Can you send me the exact string you need to parse?

As a side remark: creating a SQL string containing values literals is not the way to go: use variables instead which have the double benefit of making statement execution faster (the statement is parsed only once) and prevents SQL injection problems. Please see http://library.gnome.org/devel/libgda/unstable/GdaSqlParser.html#GdaSqlParser.description and http://library.gnome.org/devel/libgda/unstable/main_example.html for some code example.

Vivien
 


Thanks,
Johannes


_______________________________________________
gnome-db-list mailing list
gnome-db-list gnome org
http://mail.gnome.org/mailman/listinfo/gnome-db-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]