[Zope] How can you insert strings with newlines into SQL database?

Joe Pallas pallas@cs.stanford.edu
Mon, 10 Jan 2000 08:18:14 -0800


At 10:59 PM +1100 1/10/00, Anthony Baxter wrote:
> >>> Itamar Shtull-Trauring wrote
> > the problem is that if 'text' contains a newline character gadfly won't
> > accept this, since this apparently violates SQL syntax.  So I can't insert
> > strings that have newlines.  What should I do?
>
>Aaron Watters posted a patch for gadfly to fix this

Alternatively, if you don't really want newlines, tabs, etc. in the 
string, you can do what I do: _.string.join(_.string.split(text))

Or, if you want the newlines and your text is going to be displayed 
as HTML, you can encode the newlines as break tags.

I would avoid creating dependencies on a particular SQL database--you 
never know when your circumstances will change.

joe