|
||||
|
|
OOTP Mods - Database Tools Do you need to take a dump? SQL gurus welcome |
|
Thread Tools |
06-25-2006, 02:51 PM | #1 |
Hall Of Famer
Join Date: Jul 2002
Location: Detroit, MI
Posts: 3,498
|
Need some Mysql help
Using SQLyog, I have to process each batch file individually. This takes quite a bit of user interaction (54 batch files). Is there a way to combine the batch files to load them all at once or is there a way to create a new batch file that automatically uploads all of the other batch files. Sorry, I am a bit of a newb here.
Thanks |
06-25-2006, 11:27 PM | #3 |
Hall Of Famer
Join Date: Jul 2002
Location: Detroit, MI
Posts: 3,498
|
Dave,
I see your thread about the importer, but I get a tad lost with the PEAR stuff. I am running a home server on Windows 2000 with Apache, Mysql, and PHP. I created it just to make website and a message board. I have done some simple PHP scripts, but for the most part I am still new at this. I use SQLyog and PHPmyAdmin to connect to MySQL. SQLyog allows me to import a batch file, but only one at a time. If there was just a way to create a batch file that would load all of the other batch files, that would be the ideal solution for me. |
06-26-2006, 01:13 AM | #4 |
Hall Of Famer
Join Date: Jul 2002
Location: Detroit, MI
Posts: 3,498
|
Ok, i think i might be on to something here. I downloaded Text Magician (freeware http://www.david-pye.com/ ) and combined all of the .sql files into one big .sql file. I will run a test of the actual import tonight and see if it works.
|
06-26-2006, 11:46 AM | #5 |
All Star Starter
Join Date: Aug 2003
Posts: 1,146
|
If you installed your win install using one of the packages that install Apache/MySQL/PHP all in one shot, it may of already contained the Pear packages. At the very least it intalled the Pear files for you. Then all you need to do is type the following from your php installed directory
go-pear pear install DB But simply merging all files into one and then loading it will work as well. Just more steps to perform everytime you load tables. |
06-26-2006, 01:10 PM | #6 | |
Hall Of Famer
Join Date: Jul 2002
Location: Detroit, MI
Posts: 3,498
|
Quote:
|
|
06-26-2006, 01:12 PM | #7 | |
Hall Of Famer
Join Date: Jul 2002
Location: Detroit, MI
Posts: 3,498
|
Quote:
|
|
06-28-2006, 08:34 AM | #8 |
Administrator
Join Date: Jun 2002
Location: Hollern/Stade/Germany
Posts: 8,992
|
If you're having shell access to the server, you might also try this:
mysql -uusername -ppassword -t database_name < path_to_file/filename.sql This will execute all the commands from the .sql file "directly". Should be very fast, and doesn't require any 3rd party lib. Unix geeks will easily tell us how to import all sql files this way with a single line command using find and pipe or however that's called You could also write a Perl script which creates a list of sql files and makes system calls for each file. I'll post such a script here ASAP. |
06-28-2006, 09:18 PM | #9 |
Hall Of Famer
Join Date: Jul 2002
Location: Detroit, MI
Posts: 3,498
|
Thanks Andreas,
I have had no problem loading the sql files by themselves using a 3rd party or batch file. I just didnt want to have to sit in front of my computer to load each of the 54 batch files. By combining them using a text editor I only have to touch my computer to merge the files and to load the one large .sql batch file. A Perl script would be great as well |
06-30-2006, 04:57 AM | #10 |
Administrator
Join Date: Jun 2002
Location: Hollern/Stade/Germany
Posts: 8,992
|
Here is the promised Perl code to import the sql files on a server with Perl and MySQL available.
This code has not been tested and we do not offer any support for it. Use it at your own risk! It just reads a directory into a list, then skips to the list, looking for files with the wanted file name extension, then calls mysql for each file which it finds. BTW you could also add another line to unlink (delete) the file after importing it, then add the script to your crontab to be executed every 30 minutes, which will automate the process a little bit. Just an idea. Code:
#!/usr/bin/perl use strict; use CGI::Carp qw(fatalsToBrowser); my $path="/usr/local/data/whatever/"; opendir(DIRHANDLE, $path) || die "Cannot opendir /some/path: $path!"; my @dirlist=readdir(DIRHANDLE); my $name; foreach $name(@dirlist) { if (index($name,".mysql.sql") > 0) { print "Importing ".$path.$name."...\n"; system("mysql -uusername -ppassword -t database_name < ".$path.$name); } } closedir(DIRHANDLE); |
06-30-2006, 10:01 PM | #11 | |
Hall Of Famer
Join Date: Jul 2002
Location: Detroit, MI
Posts: 3,498
|
Quote:
|
|
Bookmarks |
|
|