Re: How to escape to quotes on Insert into?

From: Andre Lopes <lopes80andre(at)gmail(dot)com>
To: Bill Moran <wmoran(at)potentialtech(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to escape to quotes on Insert into?
Date: 2011-12-21 21:20:48
Message-ID: CAGFRAbNLH24tzb31YOQO_3ELPesGGb96qL9pY0W-wJYDAF9naQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks for your help. It is working.

Best Regards,

On Wed, Dec 21, 2011 at 9:04 PM, Bill Moran <wmoran(at)potentialtech(dot)com> wrote:
> In response to Andre Lopes <lopes80andre(at)gmail(dot)com>:
>
>> Hi,
>>
>> I need to escape quotes on an insert into that have a quote like this:
>>
>> http://host.com/cond'nast
>>
>> How can I escape " ' " on an insert into?
>
> It depends:
>
> The best way is to pass the string as a parametrized query, then you don't
> have to escape anything.
>
> The second best way is to use the string escape function for whatever
> language your programming in.
>
> If you don't have either of those available, you should reconsider your
> choice of language/client library, as writing your own escape functions is
> bad news.
>
> If you're forced to write the raw SQL statements for some reason, you
> escape ' with a second ', so:
> INSERT INTO tablename (colname) VALUES ('http://host.com/cond''nast');
>
> --
> Bill Moran
> http://www.potentialtech.com
> http://people.collaborativefusion.com/~wmoran/
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Xiaoning Xu 2011-12-21 21:29:51 [partition table] python fetchall or fetchone function can not get the returning rows
Previous Message Culley Harrelson 2011-12-21 21:06:59 Re: design help for performance