Hi,

When I try to insert 10 records into oracle database, 100 records are 
inserted. i.e number of records is multiplied by itself.

Please let me know if I am doing something incorrect.

    #df has 10 records.
    engine = create_engine(connection_str, echo=False)
    connection = engine.raw_connection()
    cur = connection.cursor()
    
    for rows in range(0,df.shape[0]):
        print(rows)
        values = []
        for row in range(0,df.shape[0]):
            values.append((df.iloc[row,0], df.iloc[row,1].item()))
    
        sql = """INSERT INTO {} VALUES (:1, :2)""".format('abc_tbl)
        cur.prepare(sql)
        cur.executemany(None, values)
        connection.commit()
        cur.close()
        connection.close()

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to