Thread: [cx-oracle-users] UPDATE examples
Brought to you by:
atuining
From: Robert <web...@gm...> - 2010-11-18 06:14:34
|
I searched "cx_Oracle-doc" folder for UPDATE examples but can not find any. (even Google can't seem to find any, sigh) please provide an UPDATE example (with parameters) thanks |
From: Anurag C. <anu...@gm...> - 2010-11-18 06:28:21
|
Hi Robert, Are you looking at something like this? connection = cx_Oracle.connect(Connection_String) cursor = connection.cursor() query = "UPDATE <TABLE> SET <COLUMN>=<VALUE> WHERE <Where Clause>" cursor.execute(str(query)) connection.commit() Regards, Anurag On Thu, Nov 18, 2010 at 11:44 AM, Robert <web...@gm...> wrote: > I searched "cx_Oracle-doc" folder for UPDATE examples but can not find > any. (even Google can't seem to find any, sigh) > > please provide an UPDATE example (with parameters) > > > thanks > > > ------------------------------------------------------------------------------ > Beautiful is writing same markup. Internet Explorer 9 supports > standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. > Spend less time writing and rewriting code and more time creating great > experiences on the web. Be a part of the beta today > http://p.sf.net/sfu/msIE9-sfdev2dev > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > |
From: Robert <web...@gm...> - 2010-11-18 15:44:55
|
Anurag, yes, thanks but I'm really looking for "real-world" examples, i.e. ones that uses bind variable/parameters in WHERE clause. The examples in cx_Oracle doc all seem to be simple type like you provided. On Thu, Nov 18, 2010 at 1:27 AM, Anurag Chourasia <anu...@gm...> wrote: > Hi Robert, > Are you looking at something like this? > connection = cx_Oracle.connect(Connection_String) > cursor = connection.cursor() > query = "UPDATE <TABLE> SET <COLUMN>=<VALUE> WHERE <Where Clause>" > cursor.execute(str(query)) > connection.commit() > Regards, > Anurag |
From: Anthony T. <ant...@gm...> - 2010-11-18 16:09:01
|
Hi, For "examples" I can suggest looking at the code in cx_PyOracleLib and cx_OracleTools http://cx-pyoraclelib.sourceforge.net/ http://cx-oracletools.sourceforge.net/ Those ones are "real-world". In the end, however, whether you are using updates, selects, inserts, deletes it all works exactly the same way. See below. cursor.execute(""" update sometable set somecolumn1 = :somevalue1, somecolumn2 = :somevalue2 where somecolumn3 = :somevalue3""", somevalue1 = 5, somevalue2 = "Another string of some sort", somevalue3 = "The primary key or some other such") Hope that helps you out. Anthony On Thu, Nov 18, 2010 at 8:44 AM, Robert <web...@gm...> wrote: > Anurag, yes, thanks but I'm really looking for "real-world" examples, > i.e. ones that uses bind variable/parameters in WHERE clause. > The examples in cx_Oracle doc all seem to be simple type like you provided. > > > On Thu, Nov 18, 2010 at 1:27 AM, Anurag Chourasia > <anu...@gm...> wrote: >> Hi Robert, >> Are you looking at something like this? >> connection = cx_Oracle.connect(Connection_String) >> cursor = connection.cursor() >> query = "UPDATE <TABLE> SET <COLUMN>=<VALUE> WHERE <Where Clause>" >> cursor.execute(str(query)) >> connection.commit() >> Regards, >> Anurag > > ------------------------------------------------------------------------------ > Beautiful is writing same markup. Internet Explorer 9 supports > standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. > Spend less time writing and rewriting code and more time creating great > experiences on the web. Be a part of the beta today > http://p.sf.net/sfu/msIE9-sfdev2dev > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > |
From: Mark H. <mh...@pi...> - 2010-11-18 17:34:48
|
On 11/17/10 10:14 PM, Robert wrote: > I searched "cx_Oracle-doc" folder for UPDATE examples but can not find > any. (even Google can't seem to find any, sigh) > > please provide an UPDATE example (with parameters) try one of these: # execute with positional parameter :1=first, :2=second, etc curs.execute('select :1 * :2 from dual',[2,4]) print curs.fetchone()[0] # execute with named parameter : curs.execute('select :x * :y from dual',x=2,y=5) print curs.fetchone()[0] more cx_Oracle examples at: http://markharrison.net/cx-oracle-demos HTH! Mark |
From: Robert <web...@gm...> - 2010-11-18 18:55:53
|
How to find out number of rows affected by UPDATE/DELETE... ? thanks On Thu, Nov 18, 2010 at 12:34 PM, Mark Harrison <mh...@pi...> wrote: > On 11/17/10 10:14 PM, Robert wrote: >> I searched "cx_Oracle-doc" folder for UPDATE examples but can not find >> any. (even Google can't seem to find any, sigh) >> >> please provide an UPDATE example (with parameters) > > try one of these: > > > # execute with positional parameter :1=first, :2=second, etc > curs.execute('select :1 * :2 from dual',[2,4]) > print curs.fetchone()[0] > > # execute with named parameter : > curs.execute('select :x * :y from dual',x=2,y=5) > print curs.fetchone()[0] > > > > > more cx_Oracle examples at: > > http://markharrison.net/cx-oracle-demos > > > HTH! > Mark > > ------------------------------------------------------------------------------ > Beautiful is writing same markup. Internet Explorer 9 supports > standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. > Spend less time writing and rewriting code and more time creating great > experiences on the web. Be a part of the beta today > http://p.sf.net/sfu/msIE9-sfdev2dev > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > |
From: Mark H. <mh...@pi...> - 2010-11-18 19:02:27
|
On 11/18/10 10:55 AM, Robert wrote: > How to find out number of rows affected by UPDATE/DELETE... ? > > thanks curs.rowcount should do it: curs.execute('update t1 set a=2') print curs.rowcount There's a few other handy things in the cursor class as well. |