Re: [Zope] How can you insert strings with newlines into SQL database?
Itamar Shtull-Trauring wrote I have an SQL method:
insert into mytable (col) values (<dtml-sqlvar text type="string">)
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 - you might want to check either the Zope list archives or the gadfly list archive (at egroups.com). It should probably be applied to the version that's in the Zope CVS.... Anthony -- Anthony Baxter <anthony@interlink.com.au> It's never too late to have a happy childhood.
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
participants (2)
-
Anthony Baxter -
Joe Pallas