32 lines
1.5 KiB
Python
32 lines
1.5 KiB
Python
import traceback
|
|
from geruecht.exceptions import DatabaseExecption
|
|
|
|
class Base:
|
|
def setNewRegistration(self, data):
|
|
try:
|
|
cursor = self.db.connection.cursor()
|
|
if data['entryDate']:
|
|
sql = "insert into registration_list (firstname, lastname, clubname, email, keynumber, birthdate, entrydate) VALUES ('{}', '{}', '{}', '{}', {}, '{}', '{}')".format(
|
|
data['firstName'],
|
|
data['lastName'],
|
|
data['clubName'] if data['clubName'] else 'NULL',
|
|
data['mail'],
|
|
data['keynumber'] if data['keynumber'] else 'NULL',
|
|
data['birthDate'],
|
|
data['entryDate']
|
|
)
|
|
else:
|
|
sql = "insert into registration_list (firstname, lastname, clubname, email, keynumber, birthdate) VALUES ('{}', '{}', '{}', '{}', {}, '{}')".format(
|
|
data['firstName'],
|
|
data['lastName'],
|
|
data['clubName'] if data['clubName'] else 'NULL',
|
|
data['mail'],
|
|
data['keynumber'] if data['keynumber'] else 'NULL',
|
|
data['birthDate']
|
|
)
|
|
cursor.execute(sql)
|
|
self.db.connection.commit()
|
|
except Exception as err:
|
|
traceback.print_exc()
|
|
self.db.connection.rollback()
|
|
raise DatabaseExecption("Something went worng with Databes: {}".format(err)) |