Can load data in file take ftp file location - mysql

Is there is any way to run
LOAD DATA INFILE
command, when file exists in FTP location? For example something like this:
LOAD DATA INFILE 'USER%40WEBSITE.COM:PASSWORD#ftp.WEBSITE.COM/FILE.csv';
REPLACE INTO TABLE mytable FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n' IGNORE 1 LINES

No, MySQL file-related functions can only access files on the database server or the client, but not other machines (unless you've set up a network file system mount, to make the remote machine appear to be local).

Related

Why number of rows being inserted in MySQL is less when inserted using LOAD DATA LOCAL INFILE from ruby

I am trying to insert data from text file into MySQL using LOAD DATA LOCAL INFILE command.
When I hit this command in MySQL window I get the total number of records inserted.
LOAD DATA LOCAL INFILE 'filepath' INTO TABLE tablename FIELDS TERMINATED BY '\t';
However, when I pass the same command using ruby, I see the less data is getting inserted.
connect.query("LOAD DATA LOCAL INFILE 'filepath' INTO TABLE tablename FIELDS TERMINATED BY '\\t';")
I have verified by printing the above query and it is the same.
I am using MySQL Workbench 6.3 version 6.3.10 build 12092614
If 'filepath' is a variable, is will not be expanded. Try this:
connect.query("LOAD DATA LOCAL INFILE '#{filepath}' INTO TABLE tablename FIELDS TERMINATED BY '\\t';")
If 'filepath' is a file path literal, try using an absolute path from the root. That is, if MySQL is running locally.
If this query is being submitted to a remote MySQL server, then there is no hope of it opening a local file, and you may need to rethink your import strategy completely.

Issue on Using LOAD DATA INFILE in Production Server

This code is working fine for me to load a huge .csv file into ecolo-dis-tbl table in Localhost using PHPMyAdmin and Wampserver
LOAD DATA INFILE 'C:/Data/Spreatsheets/Data-Single.csv'
INTO TABLE `ecolo-dis-tbl`
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
Now can some one please let me know how I can address the file in production server like Godaddy? I mean instead of C:/Data/Spreatsheets/ what path should use if I load the file into the root
Using phpMyAdmin you can select the Import tab and work with the file directly from your local machine. To use the SQL code you've posted here, you'll first have to upload the file to your production database server by means of SSH, FTP, or whatever other way you put files on the server. Note that for some hosts the web server is on a different machine from the database server, so you have to make sure they go on the database server. Then just use the new path (maybe something like /home/suffii/Data-Single.csv) in place of C:/Data/Spreatsheets/Data-Single.csv.

load data into the table into remote server from local machine

I have a table in database on the remote server. I want to populate the data into the that table from the local machine. I have the csv file in the local machine which has data that needs to be uploaded data into the table of remote server.
Please suggest me how can do it through mysqlimport and from where should I execute.
Thanks in advance.
Use LOAD DATA to solve this problem. Find example below:
LOAD DATA LOCAL INFILE 'filename'
INTO TABLE `tablename`
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n' (`column_name`)

Load Data In file MySQL MacOS

I'm trying to load data from a CSV using MySQL, but I'm getting Error code 29 (file not found). I'm using mac osx, but when I run the following query
LOAD DATA INFILE '/workspace/SQL_Test/src/values.csv'
INTO TABLE queryid_vs_column
COLUMNS TERMINATED BY ','
MySQL tries to look in 'C:/workspace/SQL_Test/src/values.csv'. I haven't found anyone else with similar issues, has anyone encountered something like this? I'm not sure why MySQL thinks I'm running a windows machine.
Thanks.
If you don't use the LOCAL modifier, it accesses the file on the server. Change your query to:
LOAD DATA LOCAL INFILE '/workspace/SQL_Test/src/values.csv'
INTO TABLE queryid_vs_column
COLUMNS TERMINATED BY ','

Importing Microsoft Access in to a Ruby on Rails MySQL Database

I need to import data from a Microsoft Access database through Ruby in to a MySQL database programmaticly. I need the process to be as easy as possible, as the goals is for a non technical user to obtain the access database, upload it to the Rails application, and ingest the data in to the new database.
Is there a way to do this on a Mac or Linux environment completely through Ruby?
1) export the access file as a CSV
2) you can use http://dev.mysql.com/doc/refman/5.1/en/load-data.html
example:
mysql> LOAD DATA LOCAL INFILE 'myfile.csv'
-> INTO TABLE mytable
-> FIELDS TERMINATED BY ',' ENCLOSED BY ''
-> LINES TERMINATED BY '\r\n';