#!venv/bin/python import sqlite3 import os.path def init_db(): if os.path.isfile('base.db'): return False else: conn = sqlite3.connect('base.db') cursor = conn.cursor() cursor.execute(""" CREATE TABLE IF NOT EXISTS users( Mail CHAR(80) PRIMARY KEY UNIQUE NOT NULL, name TEXT, alias TEXT, xmpp TEXT, passwd TEXT, avatar TEXT, nom TEXT, prenom TEXT, age TEXT, website TEXT, Token CHAR(30), Mail_rescue TEXT ) """) conn.commit() print ('table users OK') cursor.execute(""" CREATE TABLE IF NOT EXISTS posts( id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, title TEXT, content TEXT, time TEXT, category TEXT, author TEXT, status TEXT ) """) conn.commit() conn.close() print ('table posts OK') return True def init_dir(): if os.path.isdir('users'): return False else: os.makedirs('./users/')