Sponsored Content
Full Discussion: sh and MySQL LOAD DATA
Top Forums Shell Programming and Scripting sh and MySQL LOAD DATA Post 302297520 by worchyld on Friday 13th of March 2009 04:55:58 PM
Old 03-13-2009
I've tried it this on the actual .sql file which holds the load data stuff;

Code:
LOAD DATA LOCAL INFILE '/path/to/inbounddata/data/$(date +%Y-%m-%d)/traveldata.csv'

But I get this error;

Quote:
'/path/to/inbounddata/inbounddata/data/$(date +%Y-%m-%d)/traveldata.csv' not found (Errcode: 2)
Seems like I cannot mix and match MySQL/Shell commands inside .sql files. I tried putting the mysql date function, but this doesn't appear to work either.

Just to clarify, this is what my process is.

1. Use sh to extract contents of a zip file to a date based folder (YYYY-MM-DD)
2. Use sh to run a mysql import command

Code:
mysql -u someroot -psomepassword -h localhost somedb < /path/to/csv_import.sql

3. Import the CSV file into MySQL. The csv_import.sql is a really big long file where the LOAD DATA LOCAL INFILE exists. It needs to get the date of the latest csv file extracted.

Ideally I'd like shell to do all the heavy lifting rather than a PHP script, or perhaps there's a better way of making step 3 working?

I'm open to any ideas.

Thanks.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help in wrting Load Script for a Load-Resume type of load.

hi all need your help. I am wrting a script that will load data into the table. then on another load will append the data into the existing table. Regards Ankit (1 Reply)
Discussion started by: ankitgupta
1 Replies

2. Programming

Load text file into a MySQL field

Hello, maybe this post is offtopic, sorry for the inconveniencies. I found examples about how to populate different fields from a text file (with MySQL, the LOAD DATA INFILE sentece), but not about how to load a complete plain text file into a concrete database field. Could you please tell me if... (1 Reply)
Discussion started by: aristegui
1 Replies

3. Shell Programming and Scripting

Automatically Load data from all files in directory

I'm new in Unix shell scripting and i need someone to help me to make Script that run all time watching my directory that files uploaded to it via FTP (/mydir/incoming_files), if any files exists in it then (if many files exists, then sort files and load them ascending) it‘ll checks the size of the... (1 Reply)
Discussion started by: m_fighter
1 Replies

4. Shell Programming and Scripting

How to load different type of data in a file to two arrays

Hi, I have tried to find some sort of previous similar thread on this but not quite close to what I want to achieve. Basically I have two class of data in my file..e.g 1,1,1,1,1,2,yes 1,2,3,4,5,5,yes 2,3,4,5,5,5,no 1,2,3,4,4,2,no 1,1,3,4,5,2,no I wanted to read the "yes" entry to an... (5 Replies)
Discussion started by: ahjiefreak
5 Replies

5. Shell Programming and Scripting

executing mysql load statement from shell script

Hi, I have a piece of shell script which will connect to mysql database and execute a load statement(which will load datas in a file to the database table).The code is working and the data is in the tables. Now my requirement is, i need to grab the output from the load statement... (4 Replies)
Discussion started by: DILEEP410
4 Replies

6. Web Development

script to load data from csv file

hello i want a script to load the data line by line from a csv file into a mysql table (3 Replies)
Discussion started by: srpa01red
3 Replies

7. Shell Programming and Scripting

Load data from a flat file to oracle.

I have a flat file with records like Header 123 James Williams Finance2000 124 Pete Pete HR 1500 125 PatrickHeather Engg 3000 Footer The structure is: Eno:4 characters Name:8 characters Surname : 9 characters Dept:7 characters Sal:4characters These are sample... (1 Reply)
Discussion started by: Shivdatta
1 Replies

8. UNIX for Dummies Questions & Answers

Load UNIX data into excel sheet

Hi, i have some data in a temporary file in Unix (the data is taken from the result of an SQL query). Now i want to dump that data into an excel sheet. How to do that. Someone please advise. Thanks Regards, Vinit (3 Replies)
Discussion started by: vinit raj
3 Replies

9. Shell Programming and Scripting

Parallel sqlldr to load data.

I am using SQLLDR to load data in DB.For parallel loading I'm using nohup command. The requirement is: I have different files within a directories. Ex: 1) Dir/folder_A/AE.txt 2) Dir/folder_A/DM.txt 3) Dir/folder_B/CM.txt I need to loop through directories and load the data... (1 Reply)
Discussion started by: Pratiksha Mehra
1 Replies
MYSQL_INFO(3)								 1							     MYSQL_INFO(3)

mysql_info - Get information about the most recent query

SYNOPSIS
Warning This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include: omysqli_info(3) string mysql_info ([resource $link_identifier = NULL]) DESCRIPTION
Returns detailed information about the last query. o $ link_identifier -The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect(3) is assumed. If no such link is found, it will try to create one as if mysql_connect(3) was called with no arguments. If no connection is found or established, an E_WARNING level error is generated. Returns information about the statement on success, or FALSE on failure. See the example below for which statements provide information, and what the returned value may look like. Statements that are not listed will return FALSE. Example #1 Relevant MySQL Statements Statements that return string values. The numbers are only for illustrating purpose; their values will correspond to the query. INSERT INTO ... SELECT ... String format: Records: 23 Duplicates: 0 Warnings: 0 INSERT INTO ... VALUES (...),(...),(...)... String format: Records: 37 Duplicates: 0 Warnings: 0 LOAD DATA INFILE ... String format: Records: 42 Deleted: 0 Skipped: 0 Warnings: 0 ALTER TABLE String format: Records: 60 Duplicates: 0 Warnings: 0 UPDATE String format: Rows matched: 65 Changed: 65 Warnings: 0 Note mysql_info(3) returns a non- FALSE value for the INSERT ... VALUES statement only if multiple value lists are specified in the statement. mysql_affected_rows(3), mysql_insert_id(3), mysql_stat(3). PHP Documentation Group MYSQL_INFO(3)
All times are GMT -4. The time now is 01:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy