vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Need Advice on an Import Script (https://vborg.vbsupport.ru/showthread.php?t=75213)

Michael Morris 01-27-2005 05:55 AM

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.

Marco van Herwaarden 01-27-2005 12:07 PM

How are you making the new posts?

Manual SQL INSERT's?

Or are you using some vB functions?

miz 01-27-2005 03:47 PM

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.

Michael Morris 01-27-2005 03:49 PM

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.

miz 01-27-2005 03:55 PM

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..

Michael Morris 01-27-2005 04:01 PM

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.

Marco van Herwaarden 01-27-2005 08:27 PM

Yes i think you will have much less trouble if you insert direct into the thread/post table.

Michael Morris 01-27-2005 08:51 PM

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 :(


All times are GMT. The time now is 04:30 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01155 seconds
  • Memory Usage 1,752KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete