There is an oraklovy table on 2,5 million lines. It is necessary proapdeytit its script from Python. I read that the fetchall () method is not good to use, because the result of the query will be stored in memory. I use fetchmany (). Tell me, please, what is wrong?

def GetData(cur): v_query = """select fio_contact, id_contact from atb_segmen_email_col where fio_contact is not null""" u_query = """update atb_segmen_email_col set sex = :v1 where id_contact = :v2""" cur.execute(v_query) sql = cur.fetchmany(100) while sql: for row in sql: v_id = row[0] w = morph.parse(translit(str(row[0]), 'ru'))[0].tag.gender cur.execute(u_query, {'v1' : w, 'v2: v_id'}) cur.execute('commit') sql = cur.fetchmany(100) 

But I get an error

 cx_oracle.InterfaceError: not a query 

Maybe there is another way faster? Even before an error occurs, the update is not fast at all.

  • Corrected as is - ss_beer
  • one
    I would try to update in chunks (say 1000) using executemany () - MaxU
  • MaxU, but about the error, do not know? I guess that trail. 100 lines he can not take? - ss_beer
  • And what line swears? On cur.execute('commit') ? - MaxU
  • 2
    After the for execution, cur will contain the result of the commit, not the select. - Arnial

0