# users: # +----------+--------------+------+-----+---------+----------------+ # | Field | Type | Null | Key | Default | Extra | # +----------+--------------+------+-----+---------+----------------+ # | userID | int(11) | NO | PRI | NULL | auto_increment | # | userName | varchar(255) | NO | | NULL | | # +----------+--------------+------+-----+---------+----------------+ # # posts: # +----------+--------------+------+-----+---------+----------------+ # | Field | Type | Null | Key | Default | Extra | # +----------+--------------+------+-----+---------+----------------+ # | postID | int(11) | NO | PRI | NULL | auto_increment | # | userID | int(11) | YES | MUL | NULL | | # | title | varchar(255) | YES | | NULL | | # | content | text | YES | | NULL | | # | pubDate | varchar(255) | YES | | NULL | | # | editDate | varchar(255) | YES | | NULL | | # +----------+--------------+------+-----+---------+----------------+ from datetime import datetime import click # Used to write post content, it launches a text editor to type into # Other python files # import create_pages import config import rebuild try: import posts except: print("No posts database") try: import users except: print("No users database") import output def newpost(userID, username, datetime): title = input("Title: ") content = click.edit() content = content.replace("'", "'") content = content.replace("\n", "\n") output.log(content) datetime = datetime.now().strftime("%d%m%YZ%H%M%ST") posts.posts.append({'userID': userID, 'title': title, 'content': content, 'pubdate': datetime, 'editdate': datetime}) with open("posts.py", "w") as posts_file: posts_file.write(f"posts = {posts.posts}") rebuild.rebuild()