From b8b1f47d65d9c59bd885f3348a9ef8a3f2744ead Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan Date: Mon, 15 Nov 2010 10:51:14 +0530 Subject: [PATCH] Change wordpress import to use the newer wordpress database layout. * wordpress_to_dir.py (all_posts): select only published posts. (post_categories): get the post category based on the new set of tables wp_terms, wp_term_relationships and wp_term_taxonomy. --- wordpress-to-dir.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wordpress-to-dir.py b/wordpress-to-dir.py index 5197106..2a826e5 100644 --- a/wordpress-to-dir.py +++ b/wordpress-to-dir.py @@ -14,7 +14,8 @@ def all_posts(): sql = ('select ID, post_author, post_date_gmt, post_content,' ' post_title, post_status, comment_status, post_name,' ' post_modified_gmt, post_content_filtered' - ' from wp_posts') + ' from wp_posts WHERE post_status="publish" AND' + ' post_type ="post" ORDER BY post_date DESC') cur.execute(sql) while True: row = cur.fetchone() @@ -28,8 +29,11 @@ def all_posts(): def post_categories(post): cur = cxn.cursor() - sql = ('select cat_name from wp_categories c, wp_post2cat p2c' - ' where p2c.post_id=%s and p2c.category_id=c.cat_ID') + sql = ('select name from wp_terms INNER JOIN wp_term_taxonomy ON' + ' wp_terms.term_id = wp_term_taxonomy.term_id INNER JOIN' + ' wp_term_relationships ON wp_term_relationships.term_taxonomy_id = ' + ' wp_term_taxonomy.term_taxonomy_id WHERE' + ' wp_term_relationships.object_id=%s') cur.execute(sql, (post['id'],)) return [row[0] for row in cur.fetchall()]