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,966
    Likes Received:
    375
    Best Answers:
    0
    Trophy Points:
    245
    #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,179
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    100
    #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,224
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #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,179
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    100
    #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:
    Code (Text):
    1. <?php
    2. //Connecting to the custom database
    3. mysql_connect("localhost","root","");
    4. @mysql_select_db("new_jokes") or die( "Unable to select database");
    5.  
    6. //Querying database for content
    7. $query = "SELECT * FROM new_jokes";
    8. $result=mysql_query($query);
    9.   if (!$result)
    10.   {
    11.     print "SQL QUERY [".$sql."] FAILED ";
    12.     print "[".mysql_error()."]";
    13.   }
    14. //Exiting this database, connecting to WP database
    15. mysql_close(); //Can be commented out if this causes problems
    16. mysql_connect("localhost","root","");
    17. @mysql_select_db("laugh") or die( "Unable to select database");
    18.  
    19. $num=mysql_numrows($result);
    20. $i=0;
    21.  
    22. while ($i < $num) {
    23. $id=mysql_result($result,$i,"ID");
    24. $title=mysql_result($result,$i,"Category");
    25. $content=mysql_result($result,$i,"Joke");
    26. $uniqueurl = "http://www.laugh.com/?p=".$id;
    27.  
    28. $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)";
    29. mysql_query($query);
    30. }
    31.  
    32. mysql_close();
    33. ?>
    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,179
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    100
    #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 Active Member

    Messages:
    436
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    78
    #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