Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Strange MySQL Problem

by dragonchild (Archbishop)
on Aug 18, 2004 at 02:54 UTC ( #383839=note: print w/replies, xml ) Need Help??


in reply to Strange MySQL Problem

When I have done this type of task, I've broken it up into several discrete portions and stitched them together using a shell script. Right now, I have a daily load from a sub-optimally normalized Oracle database into a MySQL database (for generating reports). I use the following process:
  1. Oracle's SQL*Plus connections kicked off from command-line to generate tab-delimited data files
  2. A cleanup step to make sure all backslashes are backslashes, there's a \N for empty datafields, and the like. This a shell script that calls Perl in commandline.
  3. MySQL's client is kicked off in batch mode. I have to do some massaging of the data, as well, so I need to use MySQL.

While all of those things could've been done in Perl, it's a lot quicker to do it in the native client. And, the reason I wrote the second step as a shell script around commandlines is that it's easier to do

#!/bin/sh foreach f in *.xsv loop perl -pi -e 's/asdf/jkl;/g' $f endloop
than it is for me to open the file, loop through all the lines, and write the file back out. Why make it harder for yourself?

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

Replies are listed 'Best First'.
Re^2: Strange MySQL Problem
by tyndyll (Novice) on Aug 18, 2004 at 09:01 UTC

    What is the best way to implement the shell script? I am using my desktop machine for this at the moment (proof of concept) so will hopefully be moving to a Linux server afterwards... Is there a method of doing this so I don't have to rewrite the script?

    Also, does anyone have any idea why the Insert is failing? I've tried using sleep to no avail. I have noticed however that the average row length is 582 when inserted using MySQL.. don't know if that helps at all..

      Use Cygwin.

      ------
      We are the carpenters and bricklayers of the Information Age.

      Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

      I shouldn't have to say this, but any code, unless otherwise stated, is untested

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://383839]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2023-09-22 17:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?