Re: Database table load utility

2010-11-07 Thread Chap Harrison
On Nov 7, 2010, at 11:15 PM, shawn wilson wrote: > Ooh, I didn't know about inotify. Yeah, this is much more appealing. Looks like Linux::Inotify2 is better-supported than Linux::Inotify. > It would seem that you can either use it > within perl (just keep the script running like a service) or

Re: Database table load utility

2010-11-07 Thread shawn wilson
Ooh, I didn't know about inotify. It would seem that you can either use it within perl (just keep the script running like a service) or from a command line. I think it really comes down to how often you're expecting new files. And I don't know how the perl module works - its possible you might have

Re: Database table load utility

2010-11-07 Thread shawn wilson
Perl's flock and then unlink (IIRC, in perl to delete it) and move to the next one. That, or if you think you'll get too busy, check for a 'lock' file, if it doesn't exist, create it, run, then delete your lock file. On Nov 7, 2010 11:46 PM, "Chap Harrison" wrote: > > On Nov 7, 2010, at 6:47 PM, s

Re: Database table load utility

2010-11-07 Thread Ishwor Gurung
Hi. On 8 November 2010 15:46, Chap Harrison wrote: > > On Nov 7, 2010, at 6:47 PM, shawn wilson wrote: > >> its Unix, I'd use cron as its probably already running. And do something >> like: script.pl $(find -type f -print0) Every few seconds. > > That looks plenty straightforward enough, except

Re: Database table load utility

2010-11-07 Thread Chap Harrison
On Nov 7, 2010, at 6:47 PM, shawn wilson wrote: > its Unix, I'd use cron as its probably already running. And do something > like: script.pl $(find -type f -print0) Every few seconds. That looks plenty straightforward enough, except how does one prevent a race condition wherein cron launches

Re: error opening file with open function

2010-11-07 Thread Ron Bergin
Cross thread posted at http://forums.devshed.com/perl-programming-6/error-opening-csv-file-with-open-function-761095.html J M wrote: > I was able to figure it out. Here is the update (probably not final) code > for anyone interested: > > > [code] > #! /usr/bin/perl > # > use DBI; > use DBD::mysql;

Re: error opening file with open function

2010-11-07 Thread J M
I was able to figure it out. Here is the update (probably not final) code for anyone interested: [code] #! /usr/bin/perl # use DBI; use DBD::mysql; use Text::CSV; use strict; #configure variables my $host = "localhost"; my $db = "global_stats"; my $table = "station_information"; my $user = "globa

Re: error opening file with open function

2010-11-07 Thread J M
Ok now that John has helped me realize that I've been acting like a fool for the past 3 hours, I'm getting this error: DBD::mysql::st execute failed: MySQL server has gone away at [whatever line number] Thanks for your help, guys... currently I'm changing the script to use placeholders and $dbh->

Re: error opening file with open function

2010-11-07 Thread John W. Krahn
J M wrote: -- Forwarded message -- From: J M Date: Sun, Nov 7, 2010 at 8:27 PM Subject: Re: error opening file with open function To: shawn wilson shawn, I pretty sure it's not a permissions thing but here you go: [code] (jmd...@darkstar)-(0)-(07:23 PM Sun Nov 07)-> (~/global_

error opening file with open function

2010-11-07 Thread J M
-- Forwarded message -- From: J M Date: Sun, Nov 7, 2010 at 8:27 PM Subject: Re: error opening file with open function To: shawn wilson shawn, I pretty sure it's not a permissions thing but here you go: [code] (jmd...@darkstar)-(0)-(07:23 PM Sun Nov 07)-> (~/global_stats)-(5 f

Re: error opening file with open function

2010-11-07 Thread shawn wilson
Do an 'ls -l' and a 'whoami' and post the result. Also post the error your program gives. On Nov 7, 2010 9:19 PM, "J M" wrote: > I did hardcode the name in the first version of the script... in two forms: > 'file.txt' and '/home/path/to/myfile/file.txt'. Neither made any difference. > > Thank you

Re: error opening file with open function

2010-11-07 Thread J M
I did hardcode the name in the first version of the script... in two forms: 'file.txt' and '/home/path/to/myfile/file.txt'. Neither made any difference. Thank you for assisting! On Sun, Nov 7, 2010 at 8:12 PM, Parag Kalra wrote: > Instead of taking the file as an input parameter, try to parse t

Re: error opening file with open function

2010-11-07 Thread J M
On Sun, Nov 7, 2010 at 8:13 PM, shawn wilson wrote: > Use strict and warnings. Probably should also use parentheses: > open(CSV, "< $file") > On Nov 7, 2010 9:01 PM, "J M" wrote: > > Hi all, > > > > I'm having great issues with my program at the moment... it is supposed > to > > take a csv file

Re: error opening file with open function

2010-11-07 Thread shawn wilson
Use strict and warnings. Probably should also use parentheses: open(CSV, "< $file") On Nov 7, 2010 9:01 PM, "J M" wrote: > Hi all, > > I'm having great issues with my program at the moment... it is supposed to > take a csv file and parse it, with the output being stored in a MySQL > database. The

Re: error opening file with open function

2010-11-07 Thread Parag Kalra
Instead of taking the file as an input parameter, try to parse the file by hard coding its name in the script and let us know the outcome. Cheers, Parag On Sun, Nov 7, 2010 at 6:00 PM, J M wrote: > Hi all, > > I'm having great issues with my program at the moment... it is supposed to > take a

error opening file with open function

2010-11-07 Thread J M
Hi all, I'm having great issues with my program at the moment... it is supposed to take a csv file and parse it, with the output being stored in a MySQL database. The problem I'm having is that the file I need to parse ('ish_history.csv') will not open in the program for some reason. I know the fi

Re: Database table load utility

2010-11-07 Thread shawn wilson
its Unix, I'd use cron as its probably already running. And do something like: script.pl $(find -type f -print0) Every few seconds. Have the script die if ARGV[0] is undefined. I don't remember what character '-print0' puts between files -check the man pages and split on that. Loop through the fil

Database table load utility

2010-11-07 Thread Chap Harrison
Hi folks, I'm in the thinking stages of creating a table-load utility, which reads a tab-separated CSV file and inserts or updates rows in a relational table (probably Oracle). I don't think that will be too hard, having used Perl DBI/DBD modules in the past. What's different is that customer