Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'beginner': 0.05; 'insert': 0.05; 'postgresql': 0.07; 'received:192.168.178': 0.07; 'character,': 0.09; 'cursor': 0.09; 'exception,': 0.09; 'hallo,': 0.09; 'python': 0.11; '120,': 0.16; 'codec': 0.16; 'goebel': 0.16; 'ordinal': 0.16; 'received:192.168.178.20': 0.16; 'sqlite': 0.16; 'subject:values': 0.16; 'select': 0.22; 'header:User-Agent:1': 0.23; 'byte': 0.24; 'case.': 0.24; 'this:': 0.26; 'gets': 0.27; 'characters': 0.30; 'statement': 0.30; 'table': 0.34; 'subject:with': 0.35; "can't": 0.35; 'german': 0.35; 'prepare': 0.35; 'but': 0.35; 'example,': 0.37; 'sometimes': 0.38; 'ends': 0.38; 'to:addr:python-list': 0.38; 'success.': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'solve': 0.60; 'received:217': 0.63; 'statement,': 0.68; 'special': 0.74 Date: Tue, 05 Nov 2013 02:27:10 +0100 From: Ulrich Goebel User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Python Subject: Trouble with utf-8 values Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1383614829 news.xs4all.nl 15884 [2001:888:2000:d::a6]:55010 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:58473 Hallo, again: a python beginner problem... but I spent ours to solve it without success. I have an object (a variable) name, which gets its value from a PostgreSQL database via a SELECT statement, an it sometimes has german special characters as ß, ä, ö... Then I would like to insert that value into a table in a SQLite database. So I make a cursor cur on the table and prepare a SQL statement like this: sql = 'insert into tbl values(?)' cur.execute(sql, (name,)) That ends up with the exception, for example, UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 6: ordinal not in range(128) The "position 6" is exactly the position of the special character, ß in this case. What to do? Ulrich -- Ulrich Goebel Paracelsusstr. 120, 53177 Bonn