Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. dtypes1 = {c:types.VARCHAR(df[c].str.len().max()) for c in df.columns[df.dtypes == 'object'].tolist()}
  2.  
  3. df.to_sql('table1', conn2, if_exists='replace', dtype=dtypes1, index=false)
  4.  
  5. conn = create_engine('oracle+cx_oracle://.......')
  6.  
  7. SQL_statement = 'MERGE INTO ' + table2 + ' USING ' + table1 + ' ON (' + table1 + '.TIME = ' + table2 + '.TIME AND ' + table1 + '.ID = ' + table2 + '.ID) WHEN MATCHED THEN UPDATE SET ' + updateMsg + ' WHEN NOT MATCHED THEN INSERT (' + insertMsgB + ') VALUES (' + insertMsgA + ')'
  8.  
  9. conn.execute(SQL_statement)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement