Import into MySQL ".CSV" using XOJO

I have a software package that uses MS SQL Server and I have it set so that it exports 3 “.CSV” files weekly. Currently, once the files are exported and available on my desktop or “C:\DP_CSV” folder, I use PHPMyAdmin to import them into the MySQL database (one file per table) I created. Works fine except I have to do it manually. Each file takes a good minute or 2 (total 100,000 records).
In my Xojo desktop windows app, I can connect to my MySQL database, load any or all the records into a listbox, delete all the records in any of the 3 tables, and edit any record, among many things.
What I would like to do is use Xojo to import a file straight into the MySQL table. I could just click 3 different buttons, one for each file into it’s table.
If importing CSV files directly into MySQL via Xojo has been answered, could someone please point me to that answer (thanks). I can use Xojo 2019r3.1 or Xojo 2022r1.1
Thanks

The inimitable Norman Palardy wrote a CSV parser which acts like a recordset. You can find it here: GitHub - npalardy/CSVParser: Event based and recordset like CSV parser for Xojo

You can read the CSV file record by record and insert the values into your MySQL table.

1 Like

If you can connect to the MSSQL Server you could skip the csv step altogether.

3 Likes

I cannot. That’s why I am exporting the CSVs from there to MySQL so I can do what I want to do.

What about execute a system command (MySQL) and load with SQL commands?

See here, ie:

https://www.mysqltutorial.org/import-csv-file-mysql-table/

I shall test this out. Thanks

1 Like

You might even be able to maker it so that it checks a particular folder for .CSV files and it does its thing on its own when you start the app after dropping your CSV files into particular folders, maybe?

That’s exactly where I want to go. I have the CSV files (3 of them) and they get attached to 3 emails. Then, when those 3 show up in my email, the attachments are placed in a particular folder automatically. I know exactly what time that is. If I could have the app “Import” them an hour later without manual assistance, then that is the ideal solution.