Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-27-2005, 05:55 AM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Need Advice on an Import Script

I am nearing the completion of a script to import a book reviews database into vbulletin, then manipluate those files with custom files.

Anyway, I need to write an import script that will be making many posts in rapid succession as it adds the rows from the old database to the new. However, I've found the script shuts down after 10-14 posts. Is this a security feature, or do I need to insert some kind of delay loop to protect mysql from flood? I've never done this sort of thing before, so help would be appreciated.
Reply With Quote
  #2  
Old 01-27-2005, 12:07 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How are you making the new posts?

Manual SQL INSERT's?

Or are you using some vB functions?
Reply With Quote
  #3  
Old 01-27-2005, 03:47 PM
miz miz is offline
 
Join Date: Mar 2003
Posts: 416
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

here is some idea that poped up in my mind..

read the tables from old db and save them as .sql
(php will do that for 2mb per file)
now my idea is to read source of phpmyadmin
to see how its load .sql files
and to load it like phpmyadmin does
can be a good way...
its just an idea, and its might be a very bad idea but its also might work.
Reply With Quote
  #4  
Old 01-27-2005, 03:49 PM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm letting vbulletin do as much work as possible. I copied the tables from the old database into vbulletin's database temporarily with this query, one at a time.

Code:
create table forums.tablecopyinvbulletin select * from olddatabase.tabletocopy
That was done using queries from the mysql prompt and went very smoothly. Using phpmyadmin I inspected the tables to insure their data matched.

Next I've created the permanent tables for the new structure that my new vbulletin integrated program will use. For instance, the first table is "publishers" The lion's share of information on publishers on their old table is the info field. And they have a name. So I've created a "publisher data thread" and, using the post branch of the newreply.php script as a template, I constructed a while loop to read off one row of the old publisher table at a time, put the title and info into the vbulletin database (specificially the publisher data thread) and then adding some information to the cutom tables using custom queries before starting the loop again.

Yes, vbulletin inbuilt functions are being used - specifically all those appearing in that particular program branch - build_new_post key among them.

Luckily I have a local copy of vbulletin set aside specifically for this project so I can truncuate the post, thread and postindex tables and start over as necessary.

Quote:
Originally Posted by miz
here is some idea that poped up in my mind..

read the tables from old db and save them as .sql
(php will do that for 2mb per file)
now my idea is to read source of phpmyadmin
to see how its load .sql files
and to load it like phpmyadmin does
can be a good way...
its just an idea, and its might be a very bad idea but its also might work.
Thanks miz, but I'm already beyond that point using the query given above. What I need to do now is convert and merge the data from the old database into the vbulletin tables and my new custom tables.
Reply With Quote
  #5  
Old 01-27-2005, 03:55 PM
miz miz is offline
 
Join Date: Mar 2003
Posts: 416
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

so all you need is to match fileds

but you said

Quote:
I've found the script shuts down after 10-14 posts. Is this a security feature, or do I need to insert some kind of delay loop to protect mysql from flood? I've never done this sort of thing before, so help would be appreciated.
does it not shoutdown with the query
[SQL]create table forums.tablecopyinvbulletin select * from olddatabase.tabletocopy[/SQL]
??
or im confused..
Reply With Quote
  #6  
Old 01-27-2005, 04:01 PM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It shuts down after I loop through build... wait. I think I got it.... buh bye

EDIT: Nope..

This is what I have so far...

PHP Code:
<html><body>
<?php
// Reviews db conversion.

$_GET['t'] = 1;
$_GET['f'] = 5;

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once(
'./includes/functions_newpost.php');
require_once(
'./includes/functions_editor.php');
require_once(
'./includes/functions_bigthree.php');

// Rebuild Publisher

$getpublishers $DB_site->query("
    SELECT * FROM d20_publishers"
);

while (
$publisher $DB_site->fetch_array($getpublishers))
{
    
$newpost['message'] = $publisher['Info'];
    
$newpost['title'] = $publisher['publisher'];
    
$newpost['poststarttime'] = $TIMENOW;
    
$newpost['posthash'] = $TIMENOW;
    
$newpost['contactemail'] = $publisher['email'];
    
$newpost['website'] = $publisher['WWW'];
    
$newpost['founded'] = $publisher['Founded'];
    
$newpost['oldid'] = $publisher['ID'];

    
build_new_post('reply'$foruminfo$threadinfo1$newpost$errors);

    if (
sizeof($errors) > 0)
    {
        die(
'Post Error');
    }
        
    
$DB_site->query("
        INSERT INTO " 
TABLE_PREFIX "publisher(publisherid, contactemail, website, founded, oldid)
        VALUES (
$newpost[postid], '" addslashes($newpost['contactemail']) . "',
        '" 
addslashes($newpost['website']) . "', '$newpost[founded]', $newpost[oldid])
    "
);
    echo 
'Publisher #' $publisher['id'] . ' added<br />';
}

echo 
'Publishers Finished<br /><br /><br />';


?>
</body></html>
Ok, I gave up on calling build new post and ran a query directly against the post table to insert the post. I guess I figure out the problems that causes as I go along.
Reply With Quote
  #7  
Old 01-27-2005, 08:27 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes i think you will have much less trouble if you insert direct into the thread/post table.
Reply With Quote
  #8  
Old 01-27-2005, 08:51 PM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yep - that's what I ended up doing. I'll just have to rebuild the postindex afterward - a macro that can take awhile to run on large boards like EN World though
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:56 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04372 seconds
  • Memory Usage 2,254KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete