# Import into MySQL ".CSV" using XOJO

**URL:** <https://forum.xojo.com/t/import-into-mysql-csv-using-xojo/70203>\
**Category:** Databases\
**Created:** [May 13, 2022, 12:26am UTC](https://forum.xojo.com/t/import-into-mysql-csv-using-xojo/70203 "2022-05-13T00:26:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lee\_Miller](https://forum.xojo.com/user_avatar/forum.xojo.com/lee_miller/32/8905_2.png) [@Lee\_Miller](https://forum.xojo.com/u/Lee_Miller)\
**Post date:** [May 13, 2022, 12:26am UTC](https://forum.xojo.com/t/import-into-mysql-csv-using-xojo/70203/1 "2022-05-13T00:26:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [May 13, 2022, 2:27am UTC](https://forum.xojo.com/t/import-into-mysql-csv-using-xojo/70203/2 "2022-05-13T02:27:34Z")

</div>

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](https://github.com/npalardy/CSVParser)

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

---

<div class="post-metadata">

**Author:** ![Wayne\_Golding](https://forum.xojo.com/user_avatar/forum.xojo.com/wayne_golding/32/165_2.png) [@Wayne\_Golding](https://forum.xojo.com/u/Wayne_Golding)\
**Post date:** [May 13, 2022, 2:59am UTC](https://forum.xojo.com/t/import-into-mysql-csv-using-xojo/70203/3 "2022-05-13T02:59:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Lee\_Miller](https://forum.xojo.com/user_avatar/forum.xojo.com/lee_miller/32/8905_2.png) [@Lee\_Miller](https://forum.xojo.com/u/Lee_Miller)\
**Post date:** [May 13, 2022, 2:13pm UTC](https://forum.xojo.com/t/import-into-mysql-csv-using-xojo/70203/4 "2022-05-13T14:13:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![José\_María\_Terry\_Jiménez](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/fbc32d/32.png) [@José\_María\_Terry\_Jiménez](https://forum.xojo.com/u/Jos%C3%A9_Mar%C3%ADa_Terry_Jim%C3%A9nez)\
**Post date:** [May 14, 2022, 7:03pm UTC](https://forum.xojo.com/t/import-into-mysql-csv-using-xojo/70203/5 "2022-05-14T19:03:55Z")

</div>

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

See here, ie:

[https://www.mysqltutorial.org/import-csv-file-mysql-table/](https://www.mysqltutorial.org/import-csv-file-mysql-table/)

---

<div class="post-metadata">

**Author:** ![Lee\_Miller](https://forum.xojo.com/user_avatar/forum.xojo.com/lee_miller/32/8905_2.png) [@Lee\_Miller](https://forum.xojo.com/u/Lee_Miller)\
**Post date:** [May 14, 2022, 8:01pm UTC](https://forum.xojo.com/t/import-into-mysql-csv-using-xojo/70203/6 "2022-05-14T20:01:47Z")

</div>

I shall test this out. Thanks

---

<div class="post-metadata">

**Author:** ![Amy\_Barnes](https://forum.xojo.com/user_avatar/forum.xojo.com/amy_barnes/32/984_2.png) [@Amy\_Barnes](https://forum.xojo.com/u/Amy_Barnes)\
**Post date:** [May 14, 2022, 9:21pm UTC](https://forum.xojo.com/t/import-into-mysql-csv-using-xojo/70203/7 "2022-05-14T21:21:27Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Lee\_Miller](https://forum.xojo.com/user_avatar/forum.xojo.com/lee_miller/32/8905_2.png) [@Lee\_Miller](https://forum.xojo.com/u/Lee_Miller)\
**Post date:** [May 14, 2022, 9:45pm UTC](https://forum.xojo.com/t/import-into-mysql-csv-using-xojo/70203/8 "2022-05-14T21:45:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Amy\_Barnes](https://forum.xojo.com/user_avatar/forum.xojo.com/amy_barnes/32/984_2.png) [@Amy\_Barnes](https://forum.xojo.com/u/Amy_Barnes)\
**Post date:** [July 3, 2022, 2:04am UTC](https://forum.xojo.com/t/import-into-mysql-csv-using-xojo/70203/9 "2022-07-03T02:04:35Z")

</div>

Hey, I’ve been very busy at work lately and jumped back on this bc free time and holiday are good things coming together. I sent you a private message with a link to download some code I created a while back. Needs to be updated for this current version as well, but that should not be too hard.

Good luck.
