当前位置: 首页>>代码示例>>Python>>正文


Python Connector.apply_proc方法代码示例

本文整理汇总了Python中connector.Connector.apply_proc方法的典型用法代码示例。如果您正苦于以下问题:Python Connector.apply_proc方法的具体用法?Python Connector.apply_proc怎么用?Python Connector.apply_proc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在connector.Connector的用法示例。


在下文中一共展示了Connector.apply_proc方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fill_gen_add_payment

# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import apply_proc [as 别名]
def fill_gen_add_payment():
    connector = Connector()
    conn = connector.connect(secretpassword)
    cursor = conn.cursor()

    cursor.execute("select ReservationID, ToPay, ReservationDate from Reservations")
    row = cursor.fetchone()

    ratio = [i / 10 for i in range(1, 11)]

    c = Connector()
    cn = c.connect(secretpassword)

    while row:
        reservationid = row[0]
        topay = row[1]
        date = row[2]
        money_deposited = math.floor(int(topay) * random.choice(ratio))

        (y, m, d) = date.split("-")
        begin = dt.date(int(y), int(m), int(d)).toordinal()
        book_ord = dt.datetime.fromordinal(begin + random.randint(1, 7))
        date_of_payment = "/".join((str(book_ord.year), str(book_ord.month), str(book_ord.day)))

        result = (reservationid, money_deposited, date_of_payment)
        print("Add Payment " + str(result))
        c.apply_proc('GeneratorAddPayment', result)

        row = cursor.fetchone()

    conn.close()
    cn.close()
开发者ID:onegrx,项目名称:db-gen,代码行数:34,代码来源:generator.py

示例2: fill_gen_book_places_for_workshop

# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import apply_proc [as 别名]
def fill_gen_book_places_for_workshop():
    connector = Connector()
    conn = connector.connect(secretpassword)
    cursor = conn.cursor()

    cursor.execute("select Reservations.ReservationID, WorkshopID, MaxSpots "
                   "from DaysOfConf "
                   "inner join Workshops on Workshops.DayID = DaysOfConf.DayID "
                   "inner join Reservations on Reservations.DayID = DaysOfConf.DayID")
    row = cursor.fetchone()

    c = Connector()
    cn = c.connect(secretpassword)

    while row:
        reservationid = row[0]
        workshopid = row[1]
        maxspots = math.floor(row[2] / 3)

        result = (reservationid, workshopid, maxspots)
        print("Add Workshop Reservation " + str(result))
        c.apply_proc('BookPlacesForWorkshop', result)

        row = cursor.fetchone()

    conn.close()
    cn.close()
开发者ID:onegrx,项目名称:db-gen,代码行数:29,代码来源:generator.py

示例3: fill_gen_add_attendees

# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import apply_proc [as 别名]
def fill_gen_add_attendees():
    connector = Connector()
    conn = connector.connect(secretpassword)
    cursor = conn.cursor()

    cursor.execute("select company.clientid, spotsreserved from company "
                   "inner join clients on clients.clientid = company.clientid "
                   "inner join reservations on reservations.clientid = clients.clientid")
    row = cursor.fetchone()

    c = Connector()
    cn = c.connect(secretpassword)

    while row:
        clientid = row[0]
        spots_reserved = row[1]

        for reservation in range(spots_reserved):

            name, surname = getNameSurname()
            result = (clientid, name, surname)
            print("Add Attendee " + str(result))
            c.apply_proc('AddAttendee', result)

        row = cursor.fetchone()

    conn.close()
    cn.close()
开发者ID:onegrx,项目名称:db-gen,代码行数:30,代码来源:generator.py

示例4: fill_gen_book_places_for_day

# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import apply_proc [as 别名]
def fill_gen_book_places_for_day():
    connector = Connector()
    conn = connector.connect(secretpassword)
    cursor = conn.cursor()
    clients = []
    clients_getter = conn.cursor()
    clients_getter.execute("select clientid from clients")
    clients_ids = clients_getter.fetchone()
    while clients_ids:
        clients.append(clients_ids[0])
        clients_ids = clients_getter.fetchone()

    cursor.execute("select DayId, conferences.DateFrom, Spots "
                   "from DaysOfConf "
                   "inner join Conferences on conferences.ConferenceId = daysofconf.ConferenceId")
    row = cursor.fetchone()

    c = Connector()
    cn = c.connect(secretpassword)


    while row:
        dayid = row[0]
        date = row[1]
        spots_avail = row[2]

        (y, m, d) = date.split("-")
        begin = dt.date(int(y), int(m), int(d)).toordinal()

        for reservation in range(3):
            client = random.choice(clients)
            spots = random.randint(1, int(spots_avail/4))
            book_ord = dt.datetime.fromordinal(begin - random.randint(15, 80))
            date_of_book = "/".join((str(book_ord.year), str(book_ord.month), str(book_ord.day)))
            result = (dayid, client, spots, date_of_book)
            print("Book spots for the day " + str(result))
            c.apply_proc('GeneratorBookPlacesForDay', result)

        row = cursor.fetchone()

    conn.close()
    cn.close()
开发者ID:onegrx,项目名称:db-gen,代码行数:44,代码来源:generator.py

示例5: fill_gen_add_thresholds

# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import apply_proc [as 别名]
def fill_gen_add_thresholds():
    connector = Connector()
    conn = connector.connect(secretpassword)
    cursor = conn.cursor()
    cursor.execute("select * from conferences")
    row = cursor.fetchone()

    c = Connector()
    cn = c.connect(secretpassword)

    while row:
        idconf = row[0]
        dayofconf = row[2]
        for threshold in range(3):
            res = gen_add_thresholds(idconf, threshold, dayofconf)
            c.apply_proc('AddPrice', res)
            print(res)
        row = cursor.fetchone()
    conn.close()

    cn.close()
开发者ID:onegrx,项目名称:db-gen,代码行数:23,代码来源:generator.py

示例6: fill_gen_add_workshop

# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import apply_proc [as 别名]
def fill_gen_add_workshop():

    connector = Connector()
    conn = connector.connect(secretpassword)

    workshop_types_id = []
    workshop_getter = conn.cursor()
    workshop_getter.execute("select WorkshopTypeID from WorkshopType")
    types_row = workshop_getter.fetchone()
    while types_row:
        workshop_types_id.append(types_row[0])
        types_row = workshop_getter.fetchone()

    days_id = []
    days_getter = conn.cursor()
    days_getter.execute("select DayID from DaysOfConf")
    days_row = days_getter.fetchone()
    while days_row:
        days_id.append(days_row[0])
        days_row = days_getter.fetchone()

    conn.close()

    print(workshop_types_id)
    print(days_id)

    c = Connector()
    cn = c.connect(secretpassword)

    for day in days_id:
        workshop = random.choice(workshop_types_id)
        start = random.choice(["14:00:00", "15:00:00", "16:00:00"])
        end = random.choice(["18:00:00", "19:00:00", "20:00:00"])
        spots = random.choice([5, 10, 15, 20])
        price = random.randint(2, 15) * 10
        result = (workshop, day, start, end, spots, price)
        print("Add Workshop " + str(result))
        c.apply_proc('AddWorkshop', result)

    cn.close()
开发者ID:onegrx,项目名称:db-gen,代码行数:42,代码来源:generator.py


注:本文中的connector.Connector.apply_proc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。