Python formatting question
In a Python script, how can I break up a SQL statement over more than one line? For example, to transform #generate the sql statement sql="DELETE FROM tblUsers WHERE user_name LIKE '%'" to: #generate the sql statement sql="DELETE FROM tblUsers WHERE user_name LIKE '%'" ...does not work. Is there a way to break lines? Any example would be appreciated. Harlow Pinson Indepth Learning Email: hpinson@indepthl.com Web: http://www.indepthl.com Voice: 505-994-2135 FAX: 208-475-7678
----- Original Message ----- From: <hpinson@indepthl.com> To: <zope@zope.org> Sent: Thursday, July 21, 2005 12:14 PM Subject: [Zope] Python formatting question
In a Python script, how can I break up a SQL statement over more than one line? For example, to transform
#generate the sql statement sql="DELETE FROM tblUsers WHERE user_name LIKE '%'"
to:
#generate the sql statement sql="DELETE FROM tblUsers WHERE user_name LIKE '%'"
...does not work. Is there a way to break lines?
in python you can continue a logical line over several physical lines by placing a '\' character in the last position of the line you want continued. jh
--On 21. Juli 2005 10:14:32 -0600 hpinson@indepthl.com wrote:
In a Python script, how can I break up a SQL statement over more than one line? For example, to transform
# generate the sql statement sql="DELETE FROM tblUsers WHERE user_name LIKE '%'"
to:
# generate the sql statement sql="DELETE FROM tblUsers WHERE user_name LIKE '%'"
...does not work. Is there a way to break lines?
Why don't you use ZSQL methods? -aj
Perfect. Thanks for the great tips. I had looked at the various tutorials, but had not made the connection with """
Why don't you use Z SQL methods? I do, but sometimes it is more convient to do SQL through python. I also find that ZSQL encourages SQL duplication, especially among multiple developers. With a python script, the SQL calls can be stored as a single central library
Thanks again! Harlow Pinson Indepth Learning Email: hpinson@indepthl.com Web: http://www.indepthl.com Voice: 505-994-2135 FAX: 208-475-7678
--On 21. Juli 2005 10:53:41 -0600 hpinson@indepthl.com wrote:
Why don't you use Z SQL methods? I do, but sometimes it is more convient to do SQL through python. I also find that ZSQL encourages SQL duplication, especially among multiple developers. With a python script, the SQL calls can be stored as a single central library
*shivering* -aj
Why don't you use Z SQL methods? I do, but sometimes it is more convient to do SQL through python. I also find that ZSQL encourages SQL duplication, especially among multiple developers. With a python script, the SQL calls can be stored as a single central library
*shivering*
I agree with Andreas. ZSQLs are a good thing. If you mix python code and sql code you're likely to run into problems sooner or later. Bare in mind that ZSQLs aren't just a method to store the sql statement, they also have caching and other nifty functions such as parameter handling. Let me guess... you write your HTML in python code strings? :) -- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com
participants (4)
-
Andreas Jung -
hpinson@indepthl.com -
Jonathan -
Peter Bengtsson