1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How Do I convert non-wordpress sql to wordpress sql

Discussion in 'MySQL' started by Abhik, Mar 2, 2009.

  1. #1
    Hey Guys..
    I have a large database which I have bought recently.
    Its a normal sql database of articles and categories.
    Now, How can I convert it to use with wordpress?
     
    Abhik, Mar 2, 2009 IP
  2. shenron

    shenron Notable Member

    Messages:
    4,965
    Likes Received:
    374
    Best Answers:
    0
    Trophy Points:
    295
    #2
    1st you need to load the database into Mysql, then you must change the table structure to match the one used at WP, in the end all you need is to load data from 1 table into another.
    If you have more than 1 table (articles, categories, etc...) you need to have 1 table per each matching destiny.

    BTW, I suggest you do all this locally as it will be much faster (using xampp or whatever).
     
    shenron, Mar 2, 2009 IP
  3. dadaas

    dadaas Well-Known Member

    Messages:
    1,298
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    160
    #3
    Hi, i think i understand everything but how to change table structure to match wordpress db?
    My current website only have 2 tables category and jokes... and wordpress needs many other things like date, title,....
     
    dadaas, Mar 11, 2009 IP
  4. MayurGondaliya

    MayurGondaliya Well-Known Member

    Messages:
    1,233
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    170
    #4
    This is not a easy task. You need to write a script that converts other DB to wordpress DB. You need to alter tables and then import table contents. You should have the expertise in writing scripts and SQL.
     
    MayurGondaliya, Mar 12, 2009 IP
  5. dadaas

    dadaas Well-Known Member

    Messages:
    1,298
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    160
    #5
    Yea thats right. i dont ahve expertise in anything but im clsoe to fix this problem.

    Just i need advice from experts:

    what i did:
    I have tweak this script provided by Ulquiorra: http://forums.digitalpoint.com/showpost.php?p=8314776&postcount=2
    So script looks like this:
    <?php
    //Connecting to the custom database
    mysql_connect("localhost","root","");
    @mysql_select_db("new_jokes") or die( "Unable to select database");
    
    //Querying database for content
    $query = "SELECT * FROM new_jokes";
    $result=mysql_query($query);
      if (!$result)
      {
        print "SQL QUERY [".$sql."] FAILED ";
        print "[".mysql_error()."]";
      }
    //Exiting this database, connecting to WP database
    mysql_close(); //Can be commented out if this causes problems
    mysql_connect("localhost","root","");
    @mysql_select_db("laugh") or die( "Unable to select database");
    
    $num=mysql_numrows($result);
    $i=0;
    
    while ($i < $num) {
    $id=mysql_result($result,$i,"ID");
    $title=mysql_result($result,$i,"Category");
    $content=mysql_result($result,$i,"Joke");
    $uniqueurl = "http://www.laugh.com/?p=".$id;
    
    $query = "INSERT INTO wp_posts VALUES ('$id',1, '2009-01-01 00:01:00', '2009-01-01 00:01:00', '$content', '$title', 0, , 'publish', 'open', 'open', , '', , , '2009-01-02 00:00:00', '2009-01-02 00:00:00', , 0, '$uniqueurl', 0, 'post', , 0)";
    mysql_query($query);
    }
    
    mysql_close();
    ?> 
    Code (markup):
    Im going to convert it offline.
    I have install xampp and set up it to use big memory: 1gb is allowed and exectution time is 10 000 seconds, so i just want to ask if this will be enough memory and seconds to convert my jokes database into wp_posts, there are 10 000 jokes, so thats 10 000 posts.

    Can you guys check if my script is working ok? Maybe i have some error out there?

    thanks, any tips will be appreciate
     
    dadaas, Mar 12, 2009 IP
  6. dadaas

    dadaas Well-Known Member

    Messages:
    1,298
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    160
    #6
    Just to let you know I DID IT!!!

    Its pain in the ass.

    But now i have 10 000 jokes attached to my wordpress in 1 second, hehe

    Anyway if you want me to convert your content to posts let me know, im cheap, haha
    Pay per 1h is 50$
    If your database is smaller and not complicated i will sure make it in 1h.

    :)
     
    dadaas, Mar 12, 2009 IP
  7. decodethis

    decodethis Well-Known Member

    Messages:
    436
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    128
    #7
    I did something similar with another database but I created a WordPress export file (WRX) that I then imported into my blog. That also allowed me to import data into several different blogs as needed, plus I can convert to other XML-based formats at will.

    Glad you got the direct sql conversion to work though :)
     
    decodethis, Mar 12, 2009 IP
  8. moreviews2

    moreviews2 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #8
    To: Dadaas and Decodethis. I'm interested in your methods. Please send the how instructions. I'd like to be able to do it myself. Thanks.
     
    moreviews2, May 8, 2013 IP