load data

Load columnar text file into MySQL table

Ever come accoss a situation where you have to load a flat text file into MySQL with data provided in single column! Say, your data to be loaded in table looks something like this: Company1 Street Name City, MyState 8582 (999)999-999 another_Company Another Street 2 New City, NWSTATE 8582 (111)111-1111 So how’d you go about loading a text file into MySQL where field values are given in a single column!! In the above sample, data has fields like company-name, address-1, address-2 and phone given in a text file line by line. Ofcourse you can write a piece of code in...

Using LOAD DATA INFILE with Stored Procedure Workaround-MySQL

Okay! So here we will use Load Data syntax to load file into MySQL Server in a Stored procedure. Yep! It’s a workaround. Download MySQL UDF: [root@localhost kedar]# wget http://www.mysqludf.org/lib_mysqludf_sys/lib_mysqludf_sys_0.0.3.tar.gz [refer: http://www.mysqludf.org/] Extract and Install: [root@localhost kedar]# tar -xzvf lib_mysqludf_sys_0.0.3.tar.gz install.sh lib_mysqludf_sys.c lib_mysqludf_sys.html lib_mysqludf_sys.so lib_mysqludf_sys.sql Makefile [root@localhost kedar]# sh install.sh Compiling the MySQL UDF gcc -Wall -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o /usr/lib/lib_mysqludf_sys.so MySQL UDF compiled successfully Please provide your MySQL root password Enter password: MySQL UDF installed successfully Create function sys_exec as follows: CREATE FUNCTION sys_exec RETURNS INT SONAME ‘lib_mysqludf_sys.so’; sys_exec – executes an arbitrary command, and returns it’s exit...

Load Delimited Data – CSV to MySQL, Excel to MySQL Database

Loading csv to MySQL or any delimited data files to MySQL database is a very common task frequently questioned about and almost every-time LOAD DATA INFILE come into rescue. In this article I will explain you about all different scenarios and explain you how to get the data loaded directly from csv to MySQL database using single command. Download PDF Tutorial: Load data CSV to MySQL The Load Data Syntax: LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE ‘file_name’ [REPLACE | IGNORE] INTO TABLE tbl_name [CHARACTER SET charset_name] [{FIELDS | COLUMNS} [TERMINATED BY ‘string’] [[OPTIONALLY] ENCLOSED BY ‘char’] [ESCAPED BY ‘char’]...