in reply to Using an External SQL Query file?
# load all sql files as the DBUser my @sql_dirs = pkg('File')->find_all('sql'); print STDERR "Loading SQL for '$name' from " . join(', ', @sql_dir +s) . "...\n" if $verbose; $cmd = "cat " . join(' ', map { catfile($_, '*.sql') } @sql_dirs) +. " | mysql -u$user $name "; $cmd .= " -p$pass" if $pass; $cmd .= " -h$hostname" if defined $hostname; $cmd .= " -v" if $verbose > 1; print "Running '$cmd'\n" if $verbose > 1; system($cmd) && die "Couldn't load SQL: $?: $!";
That loads all the .sql files contained in an SQL directory using the mysql shell. The call in the first line is part of Krang's addon system which allows plugins to define their own SQL.
-sam
|
|---|