def test2(self): db = SqlDb(DB_URI) # test locking and re-opening cur = db.cursor() cur.close() cur = db.cursor() cur.close()
def test4(self): db = SqlDb(DB_URI) # testl locking when query failes cur = db.cursor() with self.assertRaises(Exception): cur.execute("SQL with wrong syntax") cur.close() cur = db.cursor() cur.close()
def clean_db(): db = SqlDb(DB_URI) cur = db.cursor() q = """ SHOW TABLES """ cur.execute(q) for row in cur.fetchall(): table_name = row[0] cur.execute("""DROP TABLE %s""" % table_name) cur.close()
def test1(self): db = SqlDb("mysql://root@non-existing-host/kvsql") with self.assertRaises(DatabaseError): db.cursor()
from flask import Flask, jsonify, request from flask_cors import CORS from werkzeug.utils import secure_filename import os import subprocess from db import SqlDb app = Flask(__name__) CORS(app) DB = SqlDb() def cpp(str, num, q, name): a1 = subprocess.Popen(["g++", name], stdout=subprocess.PIPE) count = 0 for i in range(1, num + 1): os.system("rm out.txt") if len(a1.stdout.readline().decode("utf-8")) > 0: return -1 a = subprocess.Popen(["cat", "./input/{0}/{1}.txt".format(q, i)], stdout=subprocess.PIPE) output = subprocess.Popen(["./a.out"], stdin=a.stdout, stdout=subprocess.PIPE) a.wait() str3 = output.stdout.readline().decode("utf-8") f = open("out.txt", "w") a = subprocess.Popen(["echo", str3], stdout=f) b = subprocess.Popen(["cat", "./output/{0}/{1}.txt".format(q, i)], stdout=subprocess.PIPE) output1 = subprocess.Popen(["python", "check.py"], stdin=b.stdout,
from db import SqlDb import re DB = SqlDb() f = open("Participants.txt", "r") f1 = f.readlines() print(f1) for i in range(len(f1)): f3 = re.split("\r|\n|\t", f1[i]) print(f3) x, y, z = f3 DB.add_entry(x, y)