<commit_before>import pymysql
import subprocess

with open("mysql_auth.txt","r") as fp:
    host = fp.readline().rstrip()
    user = fp.readline().rstrip()
    passwd = fp.readline().rstrip()
    dbname = fp.readline().rstrip()


print("Connect to MySQL server")
try:
    client = pymysql.connect(host,user,passwd,use_unicode=True,charset="utf8")
    cursor = client.cursor()
except:
    print("Connect failed")
    exit(1)

print("Dropping database \"%s\" if existed" % dbname)
cursor.execute("DROP DATABASE IF EXISTS "+dbname)
print("Creating database \"%s\"" % dbname)
cursor.execute("CREATE DATABASE %s character set utf8" % dbname)

with open("create_tables.sql","r") as file:
    subprocess.call(["mysql","-u",user,"-p"+passwd],stdin=file)

client.close()<commit_msg>add admin user and default data_type<commit_after>import pymysql
import subprocess
import bcrypt
import os

with open("mysql_auth.txt","r") as fp:
    host = fp.readline().rstrip()
    user = fp.readline().rstrip()
    passwd = fp.readline().rstrip()
    dbname = fp.readline().rstrip()


print("Connect to MySQL server")
try:
    client = pymysql.connect(host,user,passwd,use_unicode=True,charset="utf8")
    cursor = client.cursor()
except:
    print("Connect failed")
    exit(1)

print("Dropping database \"%s\" if existed" % dbname)
cursor.execute("DROP DATABASE IF EXISTS "+dbname)
print("Creating database \"%s\"" % dbname)
cursor.execute("CREATE DATABASE %s character set utf8" % dbname)

with open("create_tables.sql","r") as file:
    subprocess.call(["mysql","-u",user,"-p"+passwd],stdin=file)

client.close()

client = pymysql.connect(host,user,passwd,dbname,use_unicode=True,charset='utf8')
cursor = client.cursor()

print("create user \"admin\"")
user_name = 'admin'
user_hashed_passwd = bcrypt.hashpw('<PASSWORD>'.encode('utf-8'),bcrypt.gensalt())
ret = cursor.execute("insert into `user` (`user_name`,`user_password`) values (%s,%s)", (user_name,user_hashed_passwd))

print("create data_type \"圖片\"")
ret = cursor.execute('insert into `data_type` (`type_name`,`type_dir`) values ("圖片","圖片/")')
if not os.path.exists("static/圖片"):
    print("create dir \"圖片\"")
    os.makedirs("static/圖片")


client.commit()
client.close()
{'fraction_non_alphanumeric': 0.17774762550881953, 'fraction_numerical': 0.003618272274988693, 'mean_word_length': 5.3746397694524495, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6299248', 'n_tokens_mistral': 794, 'n_tokens_neox': 782, 'n_words': 160}