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)