Question

as in equivalence to cx_Oracle.executemany, what i could use to exclude ?

With a very simple example im using this block of code to insert data, but its possible to do it for delete entries?

try:

    con = None

    con = cx_Oracle.connect(uid , pwd, dsn)
    cur = con.cursor()
    cur.executemany(sql,params)
    con.commit()

except cx_Oracle.DatabaseError, e:

        print 'Error %s' % e
        sys.exit(1)

finally:

    if con:

        con.close()
Was it helpful?

Solution

The DB-API supports deleting multiple rows using executemany(). I do not have an Oracle database handy, but below is a tested example using SQLite:

import sqlite3
conn = sqlite3.connect(':memory:')
conn.execute('create table t (c);')
conn.executemany("insert into t values (?);", ('a','b','c',))
conn.execute('select c from t;').fetchall()
# -> [(u'a',), (u'b',), (u'c',)]
conn.executemany('delete from t where c = ?;', ('a','b',))
conn.execute('select c from t;').fetchall()
# -> [(u'c',)]
conn.close()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top