def existsAsPlayerOrCoachData(id, season, table): query = 'SELECT id FROM %s WHERE personalData_id = %s AND season_id = %s;' % ( table, str(id), str(season)) log.logDebug('%s' % (query)) sqlHandling = SqlHandling() sqlHandling.establishConnection() sqlHandling.sendQuery(query) if 0 < sqlHandling.getRowCount(): return sqlHandling.fetchOneData() sqlHandling.closeConnection() return -1
def getDefaultSeason(): query = 'SELECT id FROM season WHERE defaultseason = 1;' sqlHandling = SqlHandling() sqlHandling.establishConnection() sqlHandling.sendQuery(query) result = sqlHandling.fetchOneData() sqlHandling.closeConnection() return str(result)
def getId(data): query = 'SELECT id FROM personalData WHERE name = \"%s\" AND surname = \"%s\";' % ( data['name'], data['surname']) log.logDebug(query) sqlHandling = SqlHandling() sqlHandling.establishConnection() sqlHandling.sendQuery(query) result = -1 if 0 < sqlHandling.getRowCount(): result = sqlHandling.fetchOneData() sqlHandling.closeConnection() return result
def exists(id): query = 'SELECT id FROM playerData WHERE personalData_id = %s;' % (str(id)) log.logDebug(query) sqlHandling = SqlHandling() sqlHandling.establishConnection() sqlHandling.sendQuery(query) exists = 0 if 0 < sqlHandling.getRowCount(): exists = 1 sqlHandling.closeConnection() return exists
def existPersonInDatabase(name, surname): sqlHandling = SqlHandling() sqlHandling.establishConnection() query = 'SELECT name, surname FROM personalData WHERE name = \"' + name + '\" AND surname = \"' + surname + '\";\n' sqlHandling.sendQuery(query) data = sqlHandling.getRowCount() if data > 0: return 0 return 1
def insertIntoContact(data): sqlHandling = SqlHandling() sqlHandling.establishConnection() query = 'SELECT id FROM personalData WHERE dni = \"' + data['dni'] + '\";\n' sqlHandling.sendQuery(query) id = sqlHandling.fetchOne() if id != None: query = 'INSERT INTO contactData(address, city, zipcode, phone, email, personalData_id)' query += ' VALUES(' if data['address'] == "": query += 'NULL, ' else: query += '\"%s\",' % (data['address']) if data['city'] == "": query += 'NULL, ' else: query += '\"%s\",' % (data['city']) if data['zipcode'] == "": query += 'NULL, ' else: query += '%s, ' % (data['zipcode']) if data['phone'] == "": query += 'NULL, ' else: query += '%s, ' % (data['phone']) if data['email'] == "": query += 'NULL, ' else: query += '\"%s\", ' % (data['email']) query += '%d);\n' % (id[0]) return query return ""
def populateDB(fileGenerated): log.logInfo("Populating database") sqlHandling = SqlHandling() sqlHandling.populateDB(fileGenerated) sqlHandling.closeConnection()
def populateDB(fileGenerated): sqlHandling = SqlHandling() sqlHandling.populateDB(fileGenerated)