Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!news-transit.tcx.org.uk!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.023 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'ide': 0.05; 'rod': 0.07; 'sql.': 0.07; '%s"': 0.09; 'executes': 0.09; 'cc:name:python list': 0.16; 'privilege': 0.16; 'cc:addr:python-list': 0.16; 'wed,': 0.17; 'wrote:': 0.18; 'input': 0.22; 'header:In-Reply- To:1': 0.22; '-0500': 0.23; 'role,': 0.23; 'cc:2**0': 0.24; 'code': 0.25; '(in': 0.26; 'code.': 0.26; "i'm": 0.26; 'import': 0.27; 'script': 0.28; 'start,': 0.29; 'problem': 0.29; 'print': 0.29; 'cc:addr:python.org': 0.29; 'error': 0.29; 'nov': 0.29; 'environment': 0.30; 'roles': 0.30; 'skip:% 10': 0.30; 'anyone': 0.31; "i've": 0.31; 'does': 0.32; 'null': 0.34; 'changing': 0.35; 'something': 0.35; 'file': 0.36; 'data.': 0.36; 'club': 0.37; 'received:128': 0.37; 'doing': 0.38; 'correctly': 0.39; 'version:': 0.39; 'should': 0.39; 'appreciated.': 0.39; 'why': 0.39; '2011': 0.61; 'collect': 0.61; 'double': 0.61; 'connect': 0.62; 'union': 0.72; '"full': 0.84; '#!/bin/bash': 0.84; 'subject:SQL': 0.84; 'concluding': 0.93 Date: Wed, 30 Nov 2011 15:37:44 -0500 From: Rod Person To: Verde Denim Subject: Re: Py and SQL In-Reply-To: References: X-Mailer: Claws Mail 3.7.10cvs7 (GTK+ 2.16.6; i586-pc-mingw32msvc) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Python list X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 54 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1322685990 news.xs4all.nl 6944 [2001:888:2000:d::a6]:38063 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16449 On Wed, 30 Nov 2011 15:30:48 -0500 Verde Denim wrote: > All > I have a sql script that I've included in a simple Py file that gives > an error in the SQL. The problem is that the SQL code executes > correctly in a database IDE environment (in this case ora developer). > So, I'm concluding that I'm doing something amiss in the Py code. > Does anyone see why this code would return a 'missing expression' sql > error? Essentially, the code should start, ask for a privilege, and > then collect the priv, role, and user data. Any input is appreciated. >=20 > #!/bin/bash > import time > import cx_Oracle >=20 > dbConn =3D cx_Oracle.connect('juser', 'pass', '1.2.3.4:/orcl:DEDICATED', > cclass =3D "ABC", purity =3D cx_Oracle.ATTR_PURITY_SELF) >=20 > pStart =3D time.time() >=20 > dbVersion =3D dbConn.version.split(".") >=20 > majVer =3D dbVersion[0] >=20 > print "Oracle Version: %s" %(majVer) > print "Full Version: %s" %(dbConn.version) >=20 > dbCursor1 =3D dbConn.cursor() > 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 =3D > prior c') dbRowResult =3D dbCursor1.fetchall() > for dbRow in dbRowResult: > print dbRow >=20 Try changing the wrapping ' ' to " " and the inside double qoutes to single, like this 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 =3D prior c") --=20 Rod The club is like groceries, and I jus bag a bi@$&! =AD Santonio Holmes on the Twitter