#! /usr/bin/env python

import MySQLdb as mdb
import os
import sys
import logging
from operator import itemgetter
import warnings
import cPickle as pk

# The assumption is that the table that is being written to is cleared!

tardir = '../data/ast/'
logdir = '../log/populatedb/'

USESKIPLIST = True
#problemList = [(1,1),(1,2),(1,3),(2,6),(4,4)]
 
maxEntries = 300
MAXQUEUESIZE = 100

dbread = {}
dbread['Server'] = 'evariste'
dbread['User'] = 'codewebdb'
dbread['Pwd'] = 'n3gr0n1'
dbread['Name'] = 'codewebdb'
dbread['TableName'] = 'original_submissions'

dbwrite = {}
dbwrite['Server'] = 'evariste'
dbwrite['User'] = 'codewebdb'
dbwrite['Pwd'] = 'n3gr0n1'
dbwrite['Name'] = 'codewebdb'
dbwrite['TableName'] = 'octave'

class MultiInserter(object):
    
    def __init__(self,db,maxQueueSize):
        self.queue = []
        print('Opening database: ' + db['Name'] + '.')
        self.con = mdb.connect(db['Server'],db['User'],db['Pwd'],db['Name'])
        self.cur = self.con.cursor()
        self.db = db
        self.maxQueueSize = maxQueueSize