diff options
author | 2010-11-15 10:51:14 +0530 | |
---|---|---|
committer | 2010-11-15 22:05:15 +0100 | |
commit | b8b1f47d65d9c59bd885f3348a9ef8a3f2744ead (patch) | |
tree | 3244260e0fa0a383de522549c49727bae76a264a /wordpress-to-dir.py | |
parent | befda5cb0285d36403d405092f826e5afcff80d2 (diff) | |
download | tekuti-b8b1f47d65d9c59bd885f3348a9ef8a3f2744ead.tar.gz tekuti-b8b1f47d65d9c59bd885f3348a9ef8a3f2744ead.zip |
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.
Diffstat (limited to 'wordpress-to-dir.py')
-rw-r--r-- | wordpress-to-dir.py | 10 |
1 files 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()] |