Python Bulk Write Oracle____oracle

Source: Internet
Author: User
NP

datetimelm
arch_model cx_oracle

Column, String, create_engine  
  PD

Declare various list variables
openlist= []
Closelist = []
Highlist = []
Lowlist = []
Vollist = []
Oraengine = Create_engine (' oracle://username: password @ip:1521/service name ', echo=True)
(To say a digression, batch write MySQL also change a word, Oraengine = create_engine (' mysql://username: password @ip:1521/database name ', echo=True), Remember to Conda install Mysql-python and install this library first.
///////////////
All kinds of data append into the list.
Strcode_list.append (Strcode)
Openlist.append (Open)
/////////////////
Each type of data is aligned to a column, for example, a stock that needs to be saved for many days.
Dfdata = {"open": openlist,
            "Close": closelist,
            ' High ': highlist,
            "Low" : lowlist,
            "Vol.": Vollist,
           }
Align with this statement, prepare the data, and then to_sql the bulk insert directly
DF = PD. Dataframe (Data=dfdata)
Lenn = Len (DF)
Lenn > 0:
Df.to_sql ("Stra_stk_prog_info", Oraengine, if_exists=' append ', index=False)
A way to send an autonomic control write
Df.to_sql (DF, ' xxx ', zh_con,flavor= ' MySQL ', if_exists= ' append ', index=false,chunksize=10000)



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.