• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python dcur.execute函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pydb.dbconn.dcur.execute函数的典型用法代码示例。如果您正苦于以下问题:Python execute函数的具体用法?Python execute怎么用?Python execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get_base_amazon_data

def get_base_amazon_data(schema_name):
    if schema_name == "amazon_coins":
        a = dcur.execute(
            """
            select item_sku, 'coin', quantity
            from {0}.template;
            """.format(schema_name))

    elif schema_name == "amazon_entertainment_collectibles":
        a = dcur.execute(
            """
            select item_sku, 'coin', limited_edition_quantity
            from {0}.template;
            """.format(schema_name))
    elif schema_name == "amazon_food_service_and_jan_san":

        a = dcur.execute(
            """
            select sku, "product-name", "number-of-items"
            from {0}.template;
            """.format(schema_name))

    else:
        a = dcur.execute(
            """
            select item_sku, item_name, quantity
            from {0}.template;
            """.format(schema_name))
    a = dcur.fetchall()
    return a
开发者ID:dt1,项目名称:itemhut,代码行数:30,代码来源:amazon.py


示例2: update_pickingloc_info

def update_pickingloc_info(wh, plid, old_plname, new_plname, upc):
    if old_plname != new_plname:
        a = dcur.execute(
            """
            select *
            from warehouse.picking_locations wpp
            where exists
            (select *
            from warehouse.warehouse_picking_loc
            where picking_location_id = wpp.picking_location_id
            and warehouse_id = %s)
            and picking_location_name = %s;
            """, [wh, new_plname])
        a = dcur.fetchall()
        if a:
            return True

    a = dcur.execute(
        """
        begin;
        update warehouse.picking_locations
        set picking_location_name = %(plname)s,
        upc = %(upc)s::bigint
        where picking_location_id = %(plid)s::int;
        """, {"plname": new_plname,
              "upc": upc,
              "plid": plid})
开发者ID:dt1,项目名称:itemhut,代码行数:27,代码来源:picking_locs.py


示例3: insert_new_user

def insert_new_user(username, password, real_name,  utype, urole):
    a = dcur.execute(
        """
        select user_name
        from users.users
        where user_name = %(username)s;
        """, {"username": username})
    a = dcur.fetchall()
    if a:
        return True

    a = dcur.execute(
        """
        begin;
        insert into users.users (user_name, password, person_name,
                user_type, user_role)
        values (trim(%(user_name)s), %(password)s, 
        trim(%(person_name)s), trim(%(user_type)s), 
        trim(%(user_role)s));
        commit
        """, {"user_name": username,
              "password" :password,
              "person_name": real_name,
              "user_type": utype,
              "user_role": urole})
开发者ID:dt1,项目名称:itemhut,代码行数:25,代码来源:users.py


示例4: generate_pallet_id

def generate_pallet_id(wh):
    a = dcur.execute(
        """
        begin;
        with new_pl (pallet_location_id) as
	      (insert into warehouse.pallet_locations
		    (pallet_location_name)
	       values ('staged')
	       returning pallet_location_id)
	       ,
             new_pallet (pallet_id) as
	       (insert into warehouse.pallets (pallet_id)
		values (default)
	        returning pallet_id)
	        ,
              new_wh_palletloc as
                (insert into warehouse.warehouse_pallet_loc
		     (warehouse_id, pallet_location_id)
	         select %s, pallet_location_id
	         from new_pl)
        insert into warehouse.pallet_palletloc
             (pallet_location_id, pallet_id)
        select pallet_location_id, pallet_id
        from new_pl, new_pallet
        returning pallet_id;
        """, [wh])
    a = dcur.fetchall()
    a = dcur.execute(
        """
        commit;
        """)
    return a
开发者ID:dt1,项目名称:itemhut,代码行数:32,代码来源:warehouse.py


示例5: bulk_load_palletlocs

def bulk_load_palletlocs(f, wh):
    dcur.execute(
        """
        begin;
        create temp table pls (pallet_location_name varchar);
        """)

    ff = open(f)
    cur.copy_from(ff, "pls")

    a = dcur.execute(
        """
        with tpls (pallet_location_id) as
            (insert into warehouse.pallet_locations
                 (pallet_location_name)
             select pallet_location_name
             from pls
             where not exists
	         (select *
                  from warehouse.pallet_locations
	          join warehouse.warehouse_pallet_loc
	          using (pallet_location_id)
	          where warehouse_id = %(wh)s
	          and pallet_location_name <> pls.pallet_location_name)
              returning pallet_location_id)
        insert into warehouse.warehouse_pallet_loc
            (warehouse_id, pallet_location_id)
        select %(wh)s, pallet_location_id
        from tpls;

        drop table pls;
        commit;
        """, {"file": f,
              "wh": wh})
开发者ID:dt1,项目名称:itemhut,代码行数:34,代码来源:pallet_locs.py


示例6: add_contact

def add_contact(d):
    a = dcur.execute(
        """
        begin;
        with new_contact (contact_id) as
            (insert into company.contacts (contact_name,
                  contact_position, contact_phone, contact_phone2, 
                  contact_email)
             values (%(contact-name)s, %(position)s, %(phone-one)s, 
        %(phone-two)s, %(email)s)
             returning (company_contact_id))
        insert into company.company_contact (company_id, 
        company_contact_id)
        select %(cid)s, contact_id
        from new_contact
        returning company_contact_id;
        """, d)
    a = dcur.fetchall()

    a = dcur.execute(
        """
        commit;
        """)

    return a
开发者ID:dt1,项目名称:itemhut,代码行数:25,代码来源:companies.py


示例7: insert_pallet_location

def insert_pallet_location(wh, pl_name):
    a = dcur.execute(
        """
        select *
        from warehouse.pallet_locations
        join warehouse.warehouse_pallet_loc
        using (pallet_location_id)
        where pallet_location_name = trim(%(plname)s)
        and warehouse_id = %(wh)s;
        """, {"plname": pl_name,
              "wh": wh})
    a = dcur.fetchall()
    if a:
        return True

    a = dcur.execute(
        """
        begin;
        with new_loc (pallet_location_id) as
	    (insert into warehouse.pallet_locations
             (pallet_location_name)
	     values (%(plname)s)
	     returning pallet_location_id
	     )
        insert into warehouse.warehouse_pallet_loc
                    (warehouse_id, pallet_location_id)
        select %(wh)s, pallet_location_id
        from new_loc;
        commit;
        """, {"plname": pl_name,
              "wh": wh})
开发者ID:dt1,项目名称:itemhut,代码行数:31,代码来源:pallet_locs.py


示例8: insert_picking_location

def insert_picking_location(d):
        a = dcur.execute(
            """
            select *
            from warehouse.picking_locations wpp
            where exists
            (select *
            from warehouse.warehouse_picking_loc
            where picking_location_id = wpp.picking_location_id
            and warehouse_id = %(wh)s)
            and picking_location_name = %(plname)s;
            """, d)
        a = dcur.fetchall()
        if a:
            return True


        if d["upc"] == "":
            d["upc"] = None
            
        a = dcur.execute(
            """
            with new_plid (picking_location_id) as
                (insert into warehouse.picking_locations
                     (picking_location_name, upc)
                 values(%(plname)s, %(upc)s::bigint)
                 returning picking_location_id)
            insert into warehouse.warehouse_picking_loc
                (warehouse_id, picking_location_id)
            select %(wh)s, picking_location_id
            from new_plid;
            """, d)
开发者ID:dt1,项目名称:itemhut,代码行数:32,代码来源:picking_locs.py


示例9: insert_picking_location

def insert_picking_location(d):
    a = dcur.execute(
        """
        select warehouse_id, warehouse_name, picking_location_name
        from warehouse.warehouses
        join warehouse.warehouse_picking_loc
        using(warehouse_id)
        join warehouse.picking_locations
        using(picking_location_id)
        where warehouse_id = %(wh)s
        and picking_location_name = %(picking-location)s;
        """, d)
    a = dcur.fetchall()
    if a:
        ploc = d["picking-location"]
        whname = a[0]["warehouse_name"]
        return "{0} already exists in {1} warehouse".format(ploc, whname)

    else:
        a = dcur.execute(
            """
            with new_picking_location (new_location_id) as
	    (insert into warehouse.picking_locations
	    (picking_location_name, sku, qty)
	    values (%(picking-location)s, %(sku)s, %(upc)s::int)
	    returning picking_location_id
	    )
            insert into warehouse.warehouse_picking_loc
	    (warehouse_id, picking_location_id)
            select %(wh)s, new_location_id
            from new_picking_location;
            """, d)
    return None
开发者ID:dt1,项目名称:itemhut,代码行数:33,代码来源:warehouse.py


示例10: update_user

def update_user(original_username, username, real_name, utype,
                urole):
    if original_username != username:
        a = dcur.execute(
            """
            select user_name
            from users.users
            where user_name = %(username)s;
            """, {"username": username})
        a = dcur.fetchall()
        if a:
            return True

    if utype == "":
        utype = None

    a = dcur.execute(
        """
        begin;
        select users.update_user(%(original_username)s, 
        %(username)s, %(real_name)s, %(user_type)s, %(user_role)s);
        commit;
        """, {"original_username": original_username,
              "username": username,
              "real_name": real_name,
              "user_type": utype,
              "user_role": urole})
开发者ID:dt1,项目名称:itemhut,代码行数:27,代码来源:users.py


示例11: select_all_images

def select_all_images():
    a = dcur.execute(
        """
        select array_agg(sku) sku_list, image
        from product.image_gallery ig
        left join product.images im
        on (ig.image = im.main_image
        or ig.image = im.image_one
        or ig.image = im.image_two
        or ig.image = im.image_three
        or ig.image = im.image_four
        or ig.image = im.image_five
        or ig.image = im.image_six
        or ig.image = im.image_seven
        or ig.image = im.image_eight
        or ig.image = im.image_nine
        or ig.image = im.image_ten
        or ig.image = im.image_eleven
        or ig.image = im.image_twelve
        or ig.image = im.swatch_image)
        group by image
        order by image;       
        """
    )
    a = dcur.fetchall()
    return a
开发者ID:dt1,项目名称:itemhut,代码行数:26,代码来源:tools.py


示例12: select_pallet_locations

def select_pallet_locations(wh):
    a = dcur.execute(
        """
        select pallet_location_id, pallet_location_name, pallet_id,
        string_agg(sku || '/' || upc || ' cases(' || case_qty || ')', ';;'),
	string_agg(sku || '(' || (case_qty * piece_qty * box_qty)::varchar || ')', ';;')
        from warehouse.warehouses
        join warehouse.warehouse_pallet_loc
        using (warehouse_id)
        join warehouse.pallet_locations
        using (pallet_location_id)
        left join warehouse.pallet_palletloc
        using (pallet_location_id)
        left join warehouse.pallet_case
        using (pallet_id)
	left join warehouse.case_box
        using (case_id)
        left join warehouse.boxes
        using (box_id)
        left join product.sku_upc
        using (upc)
        where warehouse_id = %s
        group by pallet_location_id, pallet_location_name, pallet_id
        order by pallet_location_id;
        """, [wh])
    a = dcur.fetchall()
    return a
开发者ID:dt1,项目名称:itemhut,代码行数:27,代码来源:warehouse.py


示例13: add_full_pallet_to_pickingloc

def add_full_pallet_to_pickingloc(wh, pid):
        a = dcur.execute(
            """
            begin;
            with upc_count(upc, total) as
                (select upc, case_qty * piece_qty * box_qty total
                 from warehouse.pallet_palletloc
                 left join warehouse.pallet_case
                 using (pallet_id)
	         left join warehouse.case_box
                 using (case_id)
                 left join warehouse.boxes
                 using (box_id)
                 left join product.sku_upc
                 using (upc)
                 where pallet_id = %s::int
                 group by upc, total, pallet_id)
            update warehouse.picking_locations wpl
            set qty = qty + total
            from
            (select upc, total
            from upc_count) t1
            where wpl.upc = t1.upc
            and wpl.picking_location_id in
            (select picking_location_id
            from warehouse.warehouse_picking_loc
            where warehouse_id = %s);

            delete from warehouse.pallets
            where pallet_id = %s::int;
            commit;
            """, [pid, wh, pid])
开发者ID:dt1,项目名称:itemhut,代码行数:32,代码来源:warehouse.py


示例14: select_all_running_inventory

def select_all_running_inventory():
    a = dcur.execute(
        """
        select sku, upc, coalesce(total1, 0) + coalesce(total2, 0)
from
        (select sku, upc, qty total1
        from warehouse.warehouse_picking_loc
        join warehouse.picking_locations
        using (picking_location_id)
        join product.sku_upc
        using (upc)) t1

	full join

        (select sku, upc, sum(box_qty * piece_qty * case_qty) total2
        from warehouse.warehouses
        join warehouse.warehouse_pallet_loc
        using (warehouse_id)
        join warehouse.pallet_locations
        using (pallet_location_id)
        join warehouse.pallet_palletloc
        using (pallet_location_id)
        join warehouse.pallet_case
        using (pallet_id)
        join warehouse.case_box
        using (case_id)
        join warehouse.boxes
        using (box_id)
        join product.sku_upc
        using (upc)
        group by sku, upc) t2
        using (sku, upc);
        """)
    a = dcur.fetchall()
    return a
开发者ID:dt1,项目名称:itemhut,代码行数:35,代码来源:warehouse.py


示例15: running_inventory

def running_inventory(wh):
    a = dcur.execute(
        """
        select sku, upc,
        sum(coalesce(box_qty * piece_qty * case_qty, 0)
            + coalesce(qty, 0))
        from warehouse.warehouses
        join warehouse.warehouse_pallet_loc
        using (warehouse_id)
        join warehouse.pallet_locations
        using (pallet_location_id)
        join warehouse.pallet_palletloc
        using (pallet_location_id)
        join warehouse.pallet_case
        using (pallet_id)
        join warehouse.case_box
        using (case_id)
        join warehouse.boxes
        using (box_id)
        join product.sku_upc
        using (upc)
        right join warehouse.picking_locations
        using (upc)
        where warehouse_id = %s
        group by sku, upc;
        """, [wh])
    a = dcur.fetchall()
    return a
开发者ID:dt1,项目名称:itemhut,代码行数:28,代码来源:warehouse.py


示例16: sku_types

def sku_types():
    a = dcur.execute(
        """
        select sku_type
        from product.sku_types;
        """)
    a = dcur.fetchall()
    return a
开发者ID:dt1,项目名称:itemhut,代码行数:8,代码来源:product.py


示例17: insert_original_admin

def insert_original_admin(uname, password):
    a = dcur.execute(
        """
        begin;
        insert into users.users (user_name, password, user_role)
        values (%s, %s, 'original admin');
        commit;
        """, [uname, password])
开发者ID:dt1,项目名称:itemhut,代码行数:8,代码来源:login.py


示例18: select_users

def select_users():
    a = dcur.execute(
        """
        select user_name, person_name, user_type, user_role
        from users.users;
        """)
    a = dcur.fetchall()
    return a
开发者ID:dt1,项目名称:itemhut,代码行数:8,代码来源:users.py


示例19: select_valid_usertypes

def select_valid_usertypes():
    a = dcur.execute(
        """
        select user_type
        from users.valid_user_types;
        """)
    a = dcur.fetchall()
    return a
开发者ID:dt1,项目名称:itemhut,代码行数:8,代码来源:users.py


示例20: sku_upcs

def sku_upcs():
    a = dcur.execute(
        """
        select image
        from product.image_gallery
        """)
    a = dcur.fetchall()
    return a
开发者ID:dt1,项目名称:itemhut,代码行数:8,代码来源:product.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pydblite.Base类代码示例发布时间:2022-05-25
下一篇:
Python pydb.Pdb类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap