39 lines
833 B
Python
Executable File
39 lines
833 B
Python
Executable File
import mysql.connector
|
|
import config
|
|
import newpost
|
|
import rebuild
|
|
from datetime import datetime
|
|
|
|
db = mysql.connector.connect(
|
|
host=config.host,
|
|
user=config.user,
|
|
password=config.password,
|
|
database=config.database
|
|
)
|
|
|
|
cursor = db.cursor()
|
|
cursor.execute("SELECT * FROM users")
|
|
|
|
|
|
username = input("Username: ").lower()
|
|
|
|
# Check if this user exists
|
|
user_present = False
|
|
for x in cursor:
|
|
if x[1] == username:
|
|
user_present = True
|
|
userID = x[0]
|
|
if user_present == True:
|
|
print('''What do you want to do?
|
|
1. Create (N)ew post
|
|
2. (R)ebuild''')
|
|
|
|
answer = input()
|
|
if answer == 'N' or answer == '1':
|
|
newpost.newpost(db, userID, username, datetime)
|
|
if answer == 'R' or answer == '2':
|
|
rebuild.rebuild(db)
|
|
else:
|
|
print('Sorry, that account does not exist, If it should, please ask the webadmin to add this account')
|
|
db.commit()
|