<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I find it easier to code like this<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Sql = ‘’’select yadda, yadda, yadda<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>FROM a,b,c<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Where this=that<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>ORDER BY deudderting’’’<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>With the appropriate %s(varname) and % against a dictionary rather than positional args, but that’s just me.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> python-list-bounces+frsells=adventistcare.org@python.org [mailto:python-list-bounces+frsells=adventistcare.org@python.org] <b>On Behalf Of </b>Jerry Hill<br><b>Sent:</b> Wednesday, November 30, 2011 5:15 PM<br><b>To:</b> Verde Denim<br><b>Cc:</b> Python list<br><b>Subject:</b> Re: Py and SQL<o:p></o:p></span></p></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On Wed, Nov 30, 2011 at 3:30 PM, Verde Denim <<a href="mailto:tdldev@gmail.com">tdldev@gmail.com</a>> wrote:<o:p></o:p></p><p class=MsoNormal>dbCursor1.execute('select lpad(' ', 2*level) || c "Privilege, Roles and Users" from ( select null p, name c from system_privilege_map where name like upper(\'%&enter_privliege%\') union select granted_role p, grantee c from dba_role_privs union select privilege p, grantee c from dba_sys_privs) start with p is null connect by p = prior c')<o:p></o:p></p></div><p class=MsoNormal><br>I think this is your problem. Your string is delimited with single quotes on the outside ('), but you also have a mix of single and double quotes inside your string. If you were to assign this to a variable and print it out, you would probably see the problem right away. <br><br>You have two options. First, you could flip the outer quotes to double quotes, then switch all of the quotes inside the string to single quotes (I think that will work fine in SQL). Second, you could use a triple-quoted string by switching the outer quotes to ''' or """. Doing that would let you mix whatever kinds of quotes you like inside your string, like this (untested):<br><br>sql = '''select lpad(' ', 2*level) || c "Privilege, Roles and Users" from ( select null p, name c from system_privilege_map where name like upper(\'%&enter_privliege%\') union select granted_role p, grantee c from dba_role_privs union select privilege p, grantee c from dba_sys_privs) start with p is null connect by p = prior c'''<br><br>dbCursor1.execute(sql)<br><br>Once you do that, I think you will find that the "&enter_priviliege" bit in your SQL isn't going to do what you want. I assume you're expecting that to automatically pop up some sort of dialog box asking the user to enter a value for that variable? That isn't going to happen in python. That's a function of the database IDE you use. You'll need to use python to ask the user for the privilege level, then substitute it into the sql yourself.<br><br>-- <br>Jerry<o:p></o:p></p></div></body></html>