EmployeeDB/source/DataBank/createDatabank.py

56 lines
1.1 KiB
Python

import sqlalchemy as db #somehow pyodbc does not work in container
from sqlalchemy.sql import text
from sqlalchemy_utils import database_exists, create_database
'''
creates the table Mitarbeiter
IN:
the cursor/engine which is the connection object to the db
'''
def createMitarbeiter(cursor):
#write the SQL command to create the table
create = text('''CREATE TABLE IF NOT EXISTS "Mitarbeiter"
(
kuerzel varchar(50) primary key,
vorName varchar(50),
nachName varchar(50),
geschaeftsStelle varchar(50),
eintrittsDatum date,
eMail varchar(50),
telefonNummer int
)''')
cursor.execute(create)
cursor.commit()
'''
deletes the table Mitarbeiter
IN:
the cursor/engine which is the connection object to the db
'''
def dropMitarbeiter(cursor):
#write the SQL command to create the table
create = text('''DROP TABLE IF EXISTS "Mitarbeiter" ''')
cursor.execute(create)
cursor.commit()
if __name__ == '__main__':
pass