Ejemplo n.º 1
0
        def migrate_company():
            try:
                cnx = mysql.connector.connect(
                    host=self.host,
                    user=self.username,
                    password=self.password,
                    database=self.database,
                )
                cursor = cnx.cursor()
                query = "SELECT * FROM company"
                cursor.execute(query)

                for (id, name, city, timezone, alarm_email, address, tel, logo,
                     manager, extra, creator, createdat) in cursor:
                    u = Company()
                    u.id = id
                    u.name = name
                    u.city = city
                    u.timezone = timezone
                    u.alarm_email = alarm_email
                    u.address = address
                    u.telephone = tel
                    u.logo = logo
                    if manager in [0, -1]:
                        manager = 10
                    u.manager = manager
                    u.extra = extra
                    u.created_by = 10
                    u.created_on = createdat
                    db.session.add(u)
                    db.session.commit()
                cursor.close()
                cnx.close()
                return "done"
            except Exception as e:
                return str(e), 500
Ejemplo n.º 2
0
from model.internship import Internship
from model.open_internship import OpenInternship
from model.program import Program
from model.student import Student
from model.university import University

from model.university_program import university_program  # Dont remove

db.create_all()
address1 = Address("Distelstraat 6", "Schaerbeek", "Brussels", "Brussels", "Belgium", "1030")
address2 = Address("Hemeryckxlaan 10", "Kontich", "Antwerp", "Antwerp", "Belgium", "2660")
address3 = Address("Uitbreidingstraat 8", "Berchem", "Antwerp", "Antwerp", "Belgium", "2600")
address4 = Address("Celestijnenlaan 69", "", "Leuven", "Vlaams-Brabant", "Belgium", "3000")

company = Company("uza", "password", "+3212345678", "*****@*****.**", "UZA", "CPY1")
company.address = address1

program = Program("Masters in Applied Computer Science", "MACS")

student1 = Student("student1", "password1", "+3245678910", "*****@*****.**", "Jeff", "Ronald", "Bezos", "STU1")
student1.address = address2
student1.program = program

student2 = Student("student2", "password2", "+3244557766", "*****@*****.**", "John", "Bill", "Gates", "STU2")
student2.address = address4
student2.program = program

student3 = Student("student3", "password3", "+3244557786", "*****@*****.**", "Shawn", "James", "Hill", "STU3")
student3.address = address4
student3.program = program