473,387 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Selection error...

Hi..
I want to select datas but some datas give me this error:

psycopg2.ProgrammingError: invalid byte sequence for encoding "UTF8":
0xc720
HINT: This error can also happen if the byte sequence does not match
the encoding expected by the server, which is controlled by
"client_encoding".

My select command:
cursor.execute("SELECT id from templinks where url='%s'"% URL)

This problem occured only select data when i try insert the same data
it doesn't give me error..
Note: My database is UTF-8 and the URLS come from different web sites'
html code
How can i fix this problem ?
I'm sorry my bad english..

Oct 21 '07 #1
3 1519
On Sat, 2007-10-20 at 18:28 -0700, Abandoned wrote:
Hi..
I want to select datas but some datas give me this error:

psycopg2.ProgrammingError: invalid byte sequence for encoding "UTF8":
0xc720
HINT: This error can also happen if the byte sequence does not match
the encoding expected by the server, which is controlled by
"client_encoding".

My select command:
cursor.execute("SELECT id from templinks where url='%s'"% URL)
Haven't we told you before not to use the % operator to fill values into
a query? Use parameter binding:

cursor.execute("SELECT id from templinks where url=%s", (URL,) )
This problem occured only select data when i try insert the same data
it doesn't give me error..
Note: My database is UTF-8 and the URLS come from different web sites'
html code
Your string probably contains latin-1 encoded text. Try
URL.decode('latin-1').encode('utf-8') to transcode it into utf-8.

Hope this helps,

--
Carsten Haese
http://informixdb.sourceforge.net
Oct 21 '07 #2
cursor.execute("SELECT id from templinks where url=%s", (URL,) )
Yes i already try this before ask.

URL.decode('latin-1').encode('utf-8') to transcode it into utf-8.
i know this but how do you know the html encoding's a latin-1 ? Html
encoding is to be iso-8859-9 or ascii or cp1254 ... For this reason
URL.decode('latin-1').encode('utf-8') must give me error. I'm trying
now and whet it finished i write the result here.
Thank you very much for your helps.

Oct 21 '07 #3
2007/10/21, Abandoned <be*****@gmail.com>:
>
cursor.execute("SELECT id from templinks where url=%s", (URL,) )
Yes i already try this before ask.

URL.decode('latin-1').encode('utf-8') to transcode it into utf-8.
i know this but how do you know the html encoding's a latin-1 ?
Try using chardet to detect the encoding
Html
encoding is to be iso-8859-9 or ascii or cp1254 ... For this reason
URL.decode('latin-1').encode('utf-8') must give me error. I'm trying
now and whet it finished i write the result here.
Thank you very much for your helps.

--
http://mail.python.org/mailman/listinfo/python-list

--
-- Guilherme H. Polo Goncalves
Oct 21 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: carmen | last post by:
i have the folowing code Dim y As New frmCobranz Dim MyReport As New RPTCobranz MyReport.DataDefinition.RecordSelectionFormula = "{CobH.RelNbr}= y.txtNoRelac.Text...
3
by: dshan | last post by:
Hi all, I can't find an answer to my quesiton anywhere. Given a drop-down list with USA states and other text fields I pass this information for further processing via PHP. If any of the...
1
by: bvlmv | last post by:
Hello, relatively new to programming and just trying to create a simple asp page. I have the following drop down menu on a html page and when submitting i would like to call out on asp what someone...
6
by: bvlmv | last post by:
Hello, relatively new to programming and just trying to create a simple asp page. I have the following drop down menu on a html page and when submitting i would like to call out on asp what...
3
kendall
by: kendall | last post by:
I'm currently working on a PHP CMS for my school that uses simple forms to update the pages and database. To get it out in use, it will have to be usable by people who don't know that is bold, and...
2
by: makennedy | last post by:
Hi Experts, Please help, I am a newbie to ASP.NET 2.0 may be I am doing something wrong or there may be a bug somewhere. Basically I have a TreeView Control which I have created...
7
by: robtyketto | last post by:
Greetings, I'm slowly building up code to do the following:- Display TWO selection option boxes (cascading). If the FIRST selection option box changes then reload the jsp using onchange...
0
by: vjayis | last post by:
Hi i got an error while my site gets loaded Warning: mysql_query() : Unable to save result set in /path../includes/mysql.class.php on line 39 Error in Selection MySQL client ran out of memory...
1
by: HarishAdea | last post by:
Hi, I am trying to run the JAVA pgm, but it is giving error as "selection does not contain a main type". The filename is "ScoreLeadSummary.java" when i try to run it or debug,it gives the pop...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.