X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D4A03D1C910 for ; Mon, 11 Aug 2003 01:54:30 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 20181-07 for ; Sun, 10 Aug 2003 22:53:06 -0300 (ADT) Received: from lakemtao01.cox.net (lakemtao01.cox.net [68.1.17.244]) by svr1.postgresql.org (Postfix) with ESMTP id 46E90D1C513 for ; Sun, 10 Aug 2003 22:54:15 -0300 (ADT) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao01.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030811015418.CSUS7142.lakemtao01.cox.net@[192.168.1.1]> for ; Sun, 10 Aug 2003 21:54:18 -0400 Subject: Re: Punctuation problems. From: Ron Johnson To: pgsql-interfaces@postgresql.org In-Reply-To: <200308102355.25991.agh@tpg.com.au> References: <200308102355.25991.agh@tpg.com.au> Content-Type: text/plain Message-Id: <1060566859.21663.11.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.3 Date: 10 Aug 2003 20:54:19 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/42 X-Sequence-Number: 4396 On Sun, 2003-08-10 at 08:55, Alastair G. Hogge wrote: > Hello list, > > I'm using PyGreSQL to access my database to store information gathered from > HTML forms (using CGI). However I've run into a problem with some of the data > retrived. > > For example say a user of my HTML form inputs their name "Eick O'Shae". > Now when I try to store that I get problems due the ' I think. Is there a way > I can store and ' in the DB? Also are there other symbols should be aware of, > and can I store them also? This email probably isn't making much sense as I'm > very tired and have been looking at this screen for hours, but any help would > great. The escape character "\". test1=# create table foo (f text); CREATE TABLE test1=# insert into foo values ('x'); INSERT 17266 1 test1=# select * from foo; f --- x (1 row) test1=# insert into foo values ('\'x\''); INSERT 17267 1 test1=# select * from foo; f ----- x 'x' (2 rows) In Python: >>> a = "Eick O'Shae" >>> a1 = a.split("'") >>> a2 = a1[0]+"\\'"+a1[1] >>> print a2 Eick O\'Shae -- +---------------------------------------------------------------+ | Ron Johnson, Jr. Home: ron.l.johnson@cox.net | | Jefferson, LA USA | | | | "Man, I'm pretty. Hoo Hah!" | | Johnny Bravo | +---------------------------------------------------------------+