import pymysql
from model.group import Group
from model.contact import Contact


class DbFixture:

    def __init__(self, host, name, user, password):
        self.host = host
        self.name = name
        self.user = user
        self.password = password
        self.connection = pymysql.connect(host=host, database=name, user=user, password=password, autocommit=True)

    def get_group_list(self):
        list = []
        cursor = self.connection.cursor()
        try:
            cursor.execute("select group_id, group_name, group_header, group_footer from group_list")
            for row in cursor:
                (id, name, header, footer) = row
                list.append(Group(id=str(id), name=name, header=header, footer=footer))
        finally:
            cursor.close()
        return list

    def get_contact_list(self):
        list = []
        cursor = self.connection.cursor()
        try:
            cursor.execute("select id, firstname, lastname, address, mobile, home, work, phone2, email, email2, email3"
                           " from addressbook where deprecated = '0000-00-00 00:00:00'")
            for row in cursor:
                (id, firstname, lastname, address, mobile, home, work, phone2, email, email2, email3) = row
                list.append(Contact(id=str(id), firstname=firstname, lastname=lastname, address=address,
                                    mobile=mobile, home=home, work=work, phone2=phone2, email=email, email2=email2,
                                    email3=email3))
        finally:
            cursor.close()
        return list

    def get_contact_by_id(self, id_cont):
        list_cont = []
        cursor = self.connection.cursor()
        try:
            cursor.execute("select id, firstname, lastname, address, mobile, home, work, phone2, email, email2, email3"
                           "from addressbook where deprecated = '0000-00-00 00:00:00' and id='%s'" % id_cont)
            for row in cursor:
                (id, firstname, lastname, address, mobile, home, work, phone2, email, email2, email3) = row
                list_cont.append(Contact(id=str(id), firstname=firstname, lastname=lastname, address=address,
                                         mobile=mobile, home=home, work=work, phone2=phone2, email=email, email2=email2,
                                         email3=email3))
        finally:
            cursor.close()
        return list_cont

    def get_groups_with_contacts(self):
        list = []
        cursor = self.connection.cursor()
        try:
            cursor.execute("select group_id from address_in_groups")
            for row in cursor:
                (id,) = row
                list.append(Group(id=str(id)))
        finally:
            cursor.close()
        return list

    def destroy(self):
        self.connection.close()

5d25b127da97900a4e050b1926839b73dfcf95b3
<mask token>


class DbFixture:
    <mask token>
    <mask token>
    <mask token>

    def get_contact_by_id(self, id_cont):
        list_cont = []
        cursor = self.connection.cursor()
        try:
            cursor.execute(
                "select id, firstname, lastname, address, mobile, home, work, phone2, email, email2, email3from addressbook where deprecated = '0000-00-00 00:00:00' and id='%s'"
                 % id_cont)
            for row in cursor:
                (id, firstname, lastname, address, mobile, home, work,
                    phone2, email, email2, email3) = row
                list_cont.append(Contact(id=str(id), firstname=firstname,
                    lastname=lastname, address=address, mobile=mobile, home
                    =home, work=work, phone2=phone2, email=email, email2=
                    email2, email3=email3))
        finally:
            cursor.close()
        return list_cont

    def get_groups_with_contacts(self):
        list = []
        cursor = self.connection.cursor()
        try:
            cursor.execute('select group_id from address_in_groups')
            for row in cursor:
                id, = row
                list.append(Group(id=str(id)))
        finally:
            cursor.close()
        return list

    def destroy(self):
        self.connection.close()

<mask token>


class DbFixture:

    def __init__(self, host, name, user, password):
        self.host = host
        self.name = name
        self.user = user
        self.password = password
        self.connection = pymysql.connect(host=host, database=name, user=
            user, password=password, autocommit=True)

    def get_group_list(self):
        list = []
        cursor = self.connection.cursor()
        try:
            cursor.execute(
                'select group_id, group_name, group_header, group_footer from group_list'
                )
            for row in cursor:
                id, name, header, footer = row
                list.append(Group(id=str(id), name=name, header=header,
                    footer=footer))
        finally:
            cursor.close()
        return list
    <mask token>

    def get_contact_by_id(self, id_cont):
        list_cont = []
        cursor = self.connection.cursor()
        try:
            cursor.execute(
                "select id, firstname, lastname, address, mobile, home, work, phone2, email, email2, email3from addressbook where deprecated = '0000-00-00 00:00:00' and id='%s'"
                 % id_cont)
            for row in cursor:
                (id, firstname, lastname, address, mobile, home, work,
                    phone2, email, email2, email3) = row
                list_cont.append(Contact(id=str(id), firstname=firstname,
                    lastname=lastname, address=address, mobile=mobile, home
                    =home, work=work, phone2=phone2, email=email, email2=
                    email2, email3=email3))
        finally:
            cursor.close()
        return list_cont

    def get_groups_with_contacts(self):
        list = []
        cursor = self.connection.cursor()
        try:
            cursor.execute('select group_id from address_in_groups')
            for row in cursor:
                id, = row
                list.append(Group(id=str(id)))
        finally:
            cursor.close()
        return list

    def destroy(self):
        self.connection.close()

<mask token>


class DbFixture:

    def __init__(self, host, name, user, password):
        self.host = host
        self.name = name
        self.user = user
        self.password = password
        self.connection = pymysql.connect(host=host, database=name, user=
            user, password=password, autocommit=True)

    def get_group_list(self):
        list = []
        cursor = self.connection.cursor()
        try:
            cursor.execute(
                'select group_id, group_name, group_header, group_footer from group_list'
                )
            for row in cursor:
                id, name, header, footer = row
                list.append(Group(id=str(id), name=name, header=header,
                    footer=footer))
        finally:
            cursor.close()
        return list

    def get_contact_list(self):
        list = []
        cursor = self.connection.cursor()
        try:
            cursor.execute(
                "select id, firstname, lastname, address, mobile, home, work, phone2, email, email2, email3 from addressbook where deprecated = '0000-00-00 00:00:00'"
                )
            for row in cursor:
                (id, firstname, lastname, address, mobile, home, work,
                    phone2, email, email2, email3) = row
                list.append(Contact(id=str(id), firstname=firstname,
                    lastname=lastname, address=address, mobile=mobile, home
                    =home, work=work, phone2=phone2, email=email, email2=
                    email2, email3=email3))
        finally:
            cursor.close()
        return list

    def get_contact_by_id(self, id_cont):
        list_cont = []
        cursor = self.connection.cursor()
        try:
            cursor.execute(
                "select id, firstname, lastname, address, mobile, home, work, phone2, email, email2, email3from addressbook where deprecated = '0000-00-00 00:00:00' and id='%s'"
                 % id_cont)
            for row in cursor:
                (id, firstname, lastname, address, mobile, home, work,
                    phone2, email, email2, email3) = row
                list_cont.append(Contact(id=str(id), firstname=firstname,
                    lastname=lastname, address=address, mobile=mobile, home
                    =home, work=work, phone2=phone2, email=email, email2=
                    email2, email3=email3))
        finally:
            cursor.close()
        return list_cont

    def get_groups_with_contacts(self):
        list = []
        cursor = self.connection.cursor()
        try:
            cursor.execute('select group_id from address_in_groups')
            for row in cursor:
                id, = row
                list.append(Group(id=str(id)))
        finally:
            cursor.close()
        return list

    def destroy(self):
        self.connection.close()

import pymysql
from model.group import Group
from model.contact import Contact


class DbFixture:

    def __init__(self, host, name, user, password):
        self.host = host
        self.name = name
        self.user = user
        self.password = password
        self.connection = pymysql.connect(host=host, database=name, user=
            user, password=password, autocommit=True)

    def get_group_list(self):
        list = []
        cursor = self.connection.cursor()
        try:
            cursor.execute(
                'select group_id, group_name, group_header, group_footer from group_list'
                )
            for row in cursor:
                id, name, header, footer = row
                list.append(Group(id=str(id), name=name, header=header,
                    footer=footer))
        finally:
            cursor.close()
        return list

    def get_contact_list(self):
        list = []
        cursor = self.connection.cursor()
        try:
            cursor.execute(
                "select id, firstname, lastname, address, mobile, home, work, phone2, email, email2, email3 from addressbook where deprecated = '0000-00-00 00:00:00'"
                )
            for row in cursor:
                (id, firstname, lastname, address, mobile, home, work,
                    phone2, email, email2, email3) = row
                list.append(Contact(id=str(id), firstname=firstname,
                    lastname=lastname, address=address, mobile=mobile, home
                    =home, work=work, phone2=phone2, email=email, email2=
                    email2, email3=email3))
        finally:
            cursor.close()
        return list

    def get_contact_by_id(self, id_cont):
        list_cont = []
        cursor = self.connection.cursor()
        try:
            cursor.execute(
                "select id, firstname, lastname, address, mobile, home, work, phone2, email, email2, email3from addressbook where deprecated = '0000-00-00 00:00:00' and id='%s'"
                 % id_cont)
            for row in cursor:
                (id, firstname, lastname, address, mobile, home, work,
                    phone2, email, email2, email3) = row
                list_cont.append(Contact(id=str(id), firstname=firstname,
                    lastname=lastname, address=address, mobile=mobile, home
                    =home, work=work, phone2=phone2, email=email, email2=
                    email2, email3=email3))
        finally:
            cursor.close()
        return list_cont

    def get_groups_with_contacts(self):
        list = []
        cursor = self.connection.cursor()
        try:
            cursor.execute('select group_id from address_in_groups')
            for row in cursor:
                id, = row
                list.append(Group(id=str(id)))
        finally:
            cursor.close()
        return list

    def destroy(self):
        self.connection.close()

import pymysql
from model.group import Group
from model.contact import Contact


class DbFixture:

    def __init__(self, host, name, user, password):
        self.host = host
        self.name = name
        self.user = user
        self.password = password
        self.connection = pymysql.connect(host=host, database=name, user=user, password=password, autocommit=True)

    def get_group_list(self):
        list = []
        cursor = self.connection.cursor()
        try:
            cursor.execute("select group_id, group_name, group_header, group_footer from group_list")
            for row in cursor:
                (id, name, header, footer) = row
                list.append(Group(id=str(id), name=name, header=header, footer=footer))
        finally:
            cursor.close()
        return list

    def get_contact_list(self):
        list = []
        cursor = self.connection.cursor()
        try:
            cursor.execute("select id, firstname, lastname, address, mobile, home, work, phone2, email, email2, email3"
                           " from addressbook where deprecated = '0000-00-00 00:00:00'")
            for row in cursor:
                (id, firstname, lastname, address, mobile, home, work, phone2, email, email2, email3) = row
                list.append(Contact(id=str(id), firstname=firstname, lastname=lastname, address=address,
                                    mobile=mobile, home=home, work=work, phone2=phone2, email=email, email2=email2,
                                    email3=email3))
        finally:
            cursor.close()
        return list

    def get_contact_by_id(self, id_cont):
        list_cont = []
        cursor = self.connection.cursor()
        try:
            cursor.execute("select id, firstname, lastname, address, mobile, home, work, phone2, email, email2, email3"
                           "from addressbook where deprecated = '0000-00-00 00:00:00' and id='%s'" % id_cont)
            for row in cursor:
                (id, firstname, lastname, address, mobile, home, work, phone2, email, email2, email3) = row
                list_cont.append(Contact(id=str(id), firstname=firstname, lastname=lastname, address=address,
                                         mobile=mobile, home=home, work=work, phone2=phone2, email=email, email2=email2,
                                         email3=email3))
        finally:
            cursor.close()
        return list_cont

    def get_groups_with_contacts(self):
        list = []
        cursor = self.connection.cursor()
        try:
            cursor.execute("select group_id from address_in_groups")
            for row in cursor:
                (id,) = row
                list.append(Group(id=str(id)))
        finally:
            cursor.close()
        return list

    def destroy(self):
        self.connection.close()
