예제 #1
0
def database_reset_confirmation():
  db_info = mysql_util.get_db_info()
  user_input = raw_input('You are testing using database "' + db_info['db'] + \
                         '".\nThis testing will effect the tables in this database.\n' + \
                         'Do you want to continue (n/y)? ')
  if user_input != 'y' and user_input != 'Y':
    print 'Testing is cancelled'
    sys.exit()
예제 #2
0
 def setUp(self):
   self.db_info = mysql_util.get_db_info()
   self.db = MySQLdb.connect(host=self.db_info['host'], user=self.db_info['user'], \
       passwd=self.db_info['passwd'], unix_socket=self.db_info['socket'])
   self.cursor = self.db.cursor()
   if mysql_util.does_db_exist(self.db_info['db']):
     self.cursor.execute("DROP DATABASE " + self.db_info['db'])
   self.cursor.execute("CREATE DATABASE " + self.db_info['db'] + " DEFAULT CHARACTER SET 'utf8'")
   self.db.select_db(self.db_info['db'])
   self._create_test_tables()
   self.db.select_db(self.db_info['db'])
예제 #3
0
def import_papers_and_authors_tbl():
  print 'Importing papers and authors table'
  db_info = mysql_util.get_db_info()
  ngram_import_cmd = 'mysql -u' + db_info['user'] + ' -p' + db_info['passwd'] + \
      ' ' + db_info['db'] + ' < ./settings/test_sql/testseers.sql'
  os.system(ngram_import_cmd)
예제 #4
0
def import_ngrams_tbl():
  print 'Importing ngrams table'
  db_info = mysql_util.get_db_info()
  ngram_import_cmd = 'mysql -u' + db_info['user'] + ' -p' + db_info['passwd'] + \
      ' ' + db_info['db'] + ' < ./settings/test_sql/ngrams.sql'
  os.system(ngram_import_cmd)