473,288 Members | 1,729 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,288 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 1517
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: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

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.