# Collection of code snippets by Arne Vajhøj 
# (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import pymysql

with pymysql.connect(host='localhost',user='arne',password='hemmeligt',db='Test') as con:
    c = con.cursor()
    c.execute('DROP TABLE chessopening')
    c.execute('CREATE TABLE chessopening (id INTEGER NOT NULL, ' +
                                                  'names VARCHAR(255), ' +
                                                  'moves TEXT, PRIMARY KEY(id), ' +
                                                  'FULLTEXT INDEX(names,moves), ' +
                                                  'FULLTEXT INDEX(names), ' +
                                                  'FULLTEXT INDEX(moves))')
    c.execute("INSERT INTO chessopening VALUES(1, 'Spanish defense, Ruy Lopez', '1. e4, e5, 2. Nf3, Nc6, 3. Bb5,')")
    c.execute("INSERT INTO chessopening VALUES(2, 'French defense', '1. e4, e6, 2. d4, d5,')")
    c.execute("INSERT INTO chessopening VALUES(3, 'Sicilian defense', '1. e4, c5,')")
    c.execute("INSERT INTO chessopening VALUES(4, 'Queens gambit', '1. d4, d5, 2. c4,')")
    c.execute("INSERT INTO chessopening VALUES(5, 'Dutch defense', '1. d4, f5,')")
    c.execute("INSERT INTO chessopening VALUES(6, 'Reti opening', '1. Nf3, d5, 2. c4,')")
    c.close()
    con.commit()
