0

so i have a model in pandas python from csv that i process in MySQL first.

here's my query before i transform it into CSV files.

SELECT om.id AS id_pesanan,
omd.id AS order_match_detail_id,
p.name nama_produk, 
FLOOR(omd.quantity / pp.pack_size) AS total_kemasan,
omd.createdAt AS tanggal_pemesanan,
omd.price * pp.pack_size AS harga_per_pcs,
omd.createdby AS user,
awb.customer_regency AS lokasi
FROM order_match om 
JOIN order_match_detail omd ON om.id = omd.order_match_id
JOIN product p ON p.id = omd.product_id
JOIN packs pp ON omd.pack_id = pp.id
JOIN air_way_bills awb ON om.code_order = awb.code_order 
WHERE om.order_status_id IN (4,5,6,8) 
GROUP BY om.id;

and i save it into CSV with name rfm_machine_learning2

after that I transform it into CSV, and i call it using pandas to make machine learning models

df = pd.read_csv(r'D:\rfm_machine_learning2.csv')

what i want to know is, i want to make it real time models, every day in 01:00 PM that models being build, so that means for everyday, the models run, how do i do that? i've just wondering with make an event in mysql for every 01:00 PM everyday, but idk next step after that?

18818181881
  • 105
  • 7
  • 1
    Why aren't you querying mysql directly? Anyway, this is not real time, this sounds like a daily batch job, which you can take care of via your favourite task scheduler. Operating systems usually have one built-in. – Shadow Apr 06 '21 at 08:18
  • because in ```mysql``` its just only produce the data, in ```pandas``` i build the models that comes from the csv from ```mysql```, lets say, the model cant be build in directly in ```mysql``` – 18818181881 Apr 06 '21 at 09:10
  • after ```df = pd.read_csv(r'D:\rfm_machine_learning2.csv')``` there will be another next step. – 18818181881 Apr 06 '21 at 09:11
  • but I agree with you, it's not real-time, it's a daily batch job. – 18818181881 Apr 06 '21 at 09:25
  • My point was that pandas can connect to mysql directly and retrieve the data, rather than export the data to csv and import it from there to pandas. – Shadow Apr 06 '21 at 09:27
  • im sorry im new into pandas, can you suggest me what should i do in answer section? – 18818181881 Apr 06 '21 at 09:32
  • Or just could use existing answers in SO: https://stackoverflow.com/questions/12047193/how-to-convert-sql-query-result-to-pandas-data-structure – Shadow Apr 06 '21 at 11:22
  • Thank you, and how to make it so the model will automatically run for everyday – 18818181881 Apr 07 '21 at 03:00

0 Answers0