Loading values into a MYSQL database


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Loading values into a MYSQL database
# 1  
Old 12-05-2006
Loading values into a MYSQL database

Where to start?

Ok, I need to pick up a Worldpay exchange rates file from a url such as:
https://select.worldpay.com/wcc/info...op=rates-today

the http response returns a exchange rates file with content-type "text/plain" content as below:

#Exchange rates for installation 12345
#Tue Dec 05 13:28:23 GMT+00:00 2006
rateDateString=2006-12-05
allRatesCurrent=true
rateDateMillis=1165276800000
GBP_GBP=1.0
GBP_USD=1.4821286404310512
GBP_EUR=1.6173201897996292


I need to load the GBP_USD & GBP_EUR values into a MYSQL database on a nightly basis. Can anyone suggest how I could do this?

I was thinking
1. Write a shell script to to pick up the exchange rates file from the url - is this possible in unix?
2. Parse the exchange rates file in unix using awk, to get the GBP_USD & GBP_EUR exchange rates.
3. pass these values to a stored procedure to load into the database? can this be down in unix? I have executed Oracle stored procedures from unix using the SQLPLUS command, but never done this to a MYSQL database.

I'm still new to unix so I just thinking things through before I start.

Any help greatly appreciated.

Thanks.
# 2  
Old 12-05-2006
Quote:
1. Write a shell script to to pick up the exchange rates file from the url - is this possible in unix?
Yes, this'd be the natural place to start. You couldn't ask for a better input format, nothing better than UNIX for eating text. And once you've got the values it won't be difficult to stick them in a query and feed them into the database console. For getting the page itself automatically, you can use wget.
Quote:
2. Parse the exchange rates file in unix using awk, to get the GBP_USD & GBP_EUR exchange rates.
Or bash, or perl, or any other language that can read and write text. You have many options.
Quote:
3. pass these values to a stored procedure to load into the database? can this be down in unix? I have executed Oracle stored procedures from unix using the SQLPLUS command, but never done this to a MYSQL database.
mysql has a similar commandline tool. It is called, bafflingly, mysql. Smilie
Code:
tyler@mecgentoo ~ $ echo "SHOW DATABASES" | mysql -u<clipped>
Database
information_schema
inventory
mec
mec_login
parts
test
tools

# 3  
Old 12-05-2006
Great reply that, thanks it gives me somewhere to start.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to avoid locks while loading database through UNIX script.?

Hi, I have the following requirement: I have load_cdr as main scriptwhich loads all the file records into vertica database through unix script. But there are two files which try to update same table..n thats y my script is getting failed... Can any1 give me some logic how to over come this... (6 Replies)
Discussion started by: gnnsprapa
6 Replies

2. Shell Programming and Scripting

File fetching from mysql database

I have a configuration file namely: abcd, that will be use for some service (like gammu) Inside that configuration file: number1 = 66673527 number1 = 8373272 How can I make the file to search the number1 and number2 from a mysql database? Any help will be very appreciated. Thanks (1 Reply)
Discussion started by: jazzyzha
1 Replies

3. Shell Programming and Scripting

How to backup a particular Database in MYSQL?

Hi All, Thanks in Advance!! How to backup a particular Databases..through Bash script!! For example i have 6 databases; Anish linux Software Questions Rhce Google these are the databases i have from that i want to take "Anish" and "questions" database backup regularly.... (4 Replies)
Discussion started by: anishkumarv
4 Replies

4. Shell Programming and Scripting

Help with loading data from DB2 database to CSV file

Hi everyone!! I need help regarding this. How can we load data from DB2 Database tables into a Comma Separated File? I also have another Question? Using Shell scripting, Is it easy to read Data from a table or from a text file? It is very urgent for me. Please help me out guys. ... (1 Reply)
Discussion started by: ss3944
1 Replies

5. UNIX for Dummies Questions & Answers

data is seen as NULL after loading into database

hello, when I load a data from text file all the values become NULL in the table. Please help me with this problem. Thanks sheen (15 Replies)
Discussion started by: sheen
15 Replies

6. Shell Programming and Scripting

unix script for loading a data from a file into database

Hi All, I am trying to load a data from a files in a particular directory to a database.. cd $SCC isql metdb >> ${LOGDATA}/LOAD.LOG < ! load from "${LDATA}/${FORM}.ld" insert into $LOADTABLE ! But it's showing the error "syntax error at line 46 : `<<' unmatched" Can u plz help me... (5 Replies)
Discussion started by: grajesh_955
5 Replies

7. Programming

Loading mysql library error..

I am making cpp application with mysql databases. I m able to compile my application, but when i m executing the program, i m getting the loading errror as - error while loading shared libraries: libmysqlclient.so.15: cannot open shared object file: No such file or directory can any one... (2 Replies)
Discussion started by: ps_sach
2 Replies
Login or Register to Ask a Question