1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| class wordpress_post: def __init__(self,tittle,content): self.tittle=tittle self.content=content def mysql_con(self): conn = pymysql.connect(host='localhost', port=3306, user='root', passwd='pwd', db='wordpress', charset='utf8') return conn def up(self): times=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())) sql="INSERT INTO wp_posts(post_author,post_date,post_content,post_title,post_excerpt,post_status,comment_status,ping_status,post_name,to_ping,pinged,post_modified,post_content_filtered,post_parent,menu_order,post_type,comment_count) VALUES ('1','%s','%s','%s','','publish','open','open','%s','','','%s','','0','0','post','0')" % (str(times),str(self.content),str(self.tittle),str(self.tittle),str(times)) return sql def cat(self,ids,cat): sql="INSERT INTO wp_term_relationships(object_id,term_taxonomy_id,term_order) VALUES (%s,%s,'0')"%(ids,cat) return sql def close_mysql(self,cursor,conn): conn.commit() cursor.close() conn.close()
|