Automatic adding data from excel to table in MySQL - mysql

I would like load data from excel file to table. The problem is that I would like do it evry day, because data are adding to excel file in each day.
I have no problem with write script which will add data from excel to table (I use LOAD FILE) but I have problem with automatic launching these script. Is it possible in MySQL (best in MySQL WorkBench)? I need some materials, because I have never done it. I will grateful for your help.

use VBscript to call excel macro that fill the data to file then use solway's task scheduler (freeware) to execute the VBscript
for connecting to mysql via VBScript use the following
Install MySQL Connector/ODBC 5.1 and use a connection string like the following
connectionString = "Driver={MySQL ODBC 5.1 Driver};Server=yourServerAddress;Database=yourDataBase;User=yourUsername; Password=yourPassword;"

Related

MySQL Workbench 6.1 - Error importing recordset

I'm going to be getting a new computer soon and I don't want to lose all of the data I have entered in my tables, so I decided to test out the feature that allows you to export and import CSV files. I exported a table successfully (data was transferred to Microsoft Excel in CSV file), but when I opened the file in Microsoft Excel and added a few rows and tried to import it back in to MySQL Workbench, I got the following error:
"Error importing recordset
error calling Python module function
SQLIDEUtils.importRecordsetDataFromFile"
I've searched all over for info on this, but can't find any solutions. Does anyone know what I'm doing wrong?
In Workbench, open a MySQL connection and then navigate to [Server] --> [Data Export]. There are several backup options here, including saving the data as an individual file or folder. Choose the databases you want to export, and then click [Start Export].
If you ever prefer using Excel for editing and such, then use the MySQL for Excel plugin to access MySQL databases from within Excel. However, I don't think you need it here.
To export your mySQL data, use mysqldump, which will create all the schema for you.
Excel probably added some stuff to your file and now mySQL can't understand it. The best way to find out is by comparing the files before and after the change.
That error indicates a format problem. If the file is small enough, try opening it in wordpad (or the mac equivalent) and see if there's any difference in the formatting? Could be that the delimiting got a little messed up (this can happen especially with end of row markers in MySQL, I've noticed, it can also happen in mac to pc handoffs). If all else fails you could try exporting using a different format and see if that makes a difference (maybe tsv) when you add new rows.
Another reason can be the line endings used. Depending on the system and editor used to work with the cvs file it the line endings might get changed. For me mysql supported UNIX line endings. And in the editor the line ending had been set to MAC OS 9 since I was using a MAC.
Changing it to UNIX line ending worked.
I found that it might be due to a wrong encoding of the input file.
Using Notepad++ for example (or another similar editor) you need to change file encoding to UTF-8.

Easiest way to continually import data to MySQL from a dbf file on my local computer

I have a problem that has been annoying me for quite some time now and a few days ago I started googling for a solution, but I haven't really gotten anything to work. I've read a little about something called SSIS, but I'm not sure it does what I'm looking for or if there is something else I should research in order to accomplish my goal. This is my problem:
My accounting program produces and updates a .dbf file with information about all vouchers and places it in a folder on my local computer. Our MySQL must continually be updated with this information. So this is what I do twice a day:
I open up the .dbf file in excel
Save it as a .csv.
Close Excel
Open the file in notepad++
Convert the formating to utf8
Save
log in to MySQL
Go to the right table
Upload the .csv
Replace the old data with the new
As this takes quite a bit of time, I feel that there must be better ways to do this. It would be great if I could have this scheduled to be done automatically or if there is some kind of an SQL query that could do this, because then I could use PHP to make a website that I could enter and have the query run when I press a button or something.
So my question is: What is the most simple way to continually get the info from the .dbf file into my SQL server?
There is a way to do your job by shedule with DBF Commander Pro's command-line interface. Use the following command in a *.BAT file:
dbfcommander.exe -edb <dbf_file_name> <server_table_name> <connection_string>
After that, create a shedule for this BAT file using Windows Sheduler.
The only issue remains, that you need to clear the destination table on MySQL database before the export process.
In order to try the export process in app GUI, click 'File -> Export to DBMS'. In the window appears click Build button in order to build the connection string: select MS OLEDB Provider for MySQL Server, then choose your server from the list, provide login and password, select a database, click OK:
In the Export to DBMS window select the destination table you want to import source DBF file to, then click Export. The command line you need you can find at the bottom part of the window.
More info on import and export DBF to a database you can find here. Detailed using of command-line is here.
As you mention of doing in PHP. What is stopping you from doing it there.
You could create one connection handle using a VFPOleDB provider to open the path location of the table, open and read the table. Then have a SECOND connection to your MySQL database open and ready to push the data there.
Then, for each row read from the VFP OleDB connection result set, do whatever special cleansing you need to.
Then, query from the MySQL connection if its an existing entry or not and if an add or update is necessary, then send the data respectively.
Continue for the rest of the records from the VFP result set.
No need to open in Excel, save to CSV format, load yet another tool, etc...

How to insert particular excel file fields records into sqlserver database table manually

I am facing some problem with inserting data from excel file to sqlserver database table. kindly suggest me what i need to do?
i.e. i am having bulk copy of data in various excel files. from that excel files, only selected fields of data would be inserted into sqlserver database table.
how can i achieve this functionality manually.
kindly give me reference sites & suggestions.
Thanks in Advance
Satish Chandragiri
I would connect to the SQL Server DB via VBA from some excel workbook and browse that bulk of Excel files and insert all the data to the DB. The link below shows how to connect to the SQL Server database.
http://www.mrexcel.com/forum/excel-questions/617788-visual-basic-applications-connect-sql-server.html

Exporting a Mysql database to Access?

I see there are multiple ways to do exports from mysql - the list phpmyadmin provides is given below:
I vote for the easiest way. For example I can get a .sql file from the SQL option but I don't know where to go from there. Likewise I can get a .php file but I don't know how to parse it from there into Access. Thanks!
Codegen, CSV, CSV for MS Excel, MS Word 2000, latex, Media Wiki Table, Open Document Spreadsheet, Open Document Text, PDF, PHP Array, SQL, Texy text, Excel 97-2003, Excel 2007, XML, YAML
Export Working: PHP Array(.php), SQL (.sql)
Export Not Working: XML
Ambiguous: Excel 2007
I would install a MySQL ODBC driver, create a DSN pointing to your MySQL database, then use the Access UI option to import from ODBC. If you want a code approach, use the DoCmd.TransferDatabase Method
Alternatively, you could create ODBC links in Access to your MySQL tables, then run "Make-Table" queries to create Access copies of those tables:
SELECT * INTO new_access_table
FROM mysql_linked_table;

How to extract data from excel file into the database in Mysql at runtime in asp.net?

I am creating a website...and i want to give a liberty to users, to upload the data of excel file and then i want to save that excel data inside mysql database on runtime...
kindly help me in performing this task...
you can mail me at...."amiteshsinha09#rediffmail.com"
thank you
Amitesh
You can query the data in the excel sheet using Open Xml
Using this instead of running Excel via interop is both faster, more stable and saves you licence costs.