def init_db(): print 'Initialising database, and inserting schema.' schema = False if settings.DATABASE_TYPE.lower() in ('sqlite', 'sqlite3'): schema = 'schema_sqlite3.sql' db_t = 'sqlite' elif settings.DATABASE_TYPE.lower() in ('mysql'): schema = 'schema_mysql.sql' db_t = 'mysql' if not schema: print 'Given database type was not valid, bailing.' sys.exit(1) pysql = pysql_() # Stupid workarounds because MySQL doesn't support .executescript() if db_t == 'sqlite': with open('zkpm{0}{1}'.format(os.sep, schema), 'rb') as f: pysql._cursor.executescript(f.read()) pysql._dbc.commit() elif db_t == 'mysql': with open('zkpm{0}{1}'.format(os.sep, schema), 'rb') as f: for line in f.readlines(): print line pysql = pysql_() pysql.query(line) print 'Database initialised.'
def submit_details(username, password, email): pysql = pysql_() data = { "login": username.lower(), "username": username, "password": hash_pass(username, password), "email": email } pysql.insert('users', data)