From 58035b085f52ab58f7dbfe05b1bbd28148a49354 Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 4 Jan 2019 19:48:11 +0100 Subject: [PATCH] Automatically publish planned blog posts --- publish_blog_posts.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 publish_blog_posts.py diff --git a/publish_blog_posts.py b/publish_blog_posts.py new file mode 100644 index 0000000..a0a7ad9 --- /dev/null +++ b/publish_blog_posts.py @@ -0,0 +1,21 @@ +import shutil + +import pymysql + +db = pymysql.connect('localhost', 'kingofdog', '123456', 'kingofdog') +cur = db.cursor() + +try: + unpublished_posts = cur.execute('update blog_posts set postState = 1 where postState = 3 and postPublishDate < now()') + db.commit() + shutil.rmtree('admin+blog') + shutil.rmtree('blog+index') + shutil.rmtree('blog+search') + shutil.rmtree('blog+tag') + shutil.rmtree('blog+category') + shutil.rmtree('blog+post') +except: + print('it didnt work') + db.rollback() + +db.close() \ No newline at end of file