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


Python Target.mkTarget方法代码示例

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


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

示例1: buildData

# 需要导入模块: import Target [as 别名]
# 或者: from Target import mkTarget [as 别名]
    def buildData(self, search):

        lst = []
        counter = 0
        counterTotal = 0

        t = Target.mkTarget(search)

        add_food = ("INSERT INTO food "
                   "(name, price, weight, location) "
                   "VALUES (%s, %s, %s, %s)")

        add_search = ("INSERT INTO search_type "
                   "(id, search, points) "
                   "VALUES (%s, %s, %s)")

        add_fc = ("INSERT INTO fc "
                   "(category, count, search, feature) "
                   "VALUES (%s, %s, %s, %s)")

        add_cc = ("INSERT INTO cc "
                   "(count, search, category) "
                   "VALUES (%s, %s, %s)")

        self.cursor.execute(add_cc, (0, search,1))
        self.database.commit()
        self.cursor.execute(add_cc, (0, search,0))
        self.database.commit()
        print("hi")
        for i in t:
            counterTotal += 1

        #    print(i.n +' '+ str(i.p))

            if self.findDuplicate(i,search) == 1:
                print("i'm in here all ready")

            else:
                print("i'm here to stay bitches")
                lst.append(i)
                try:
                    food_data = (i.n, float(i.p), float(i.w), "target")
                    self.cursor.execute(add_food,food_data)
                    self.database.commit()
                    foodID = self.cursor.lastrowid
                    search_data = (foodID, search, 0)
                    self.cursor.execute(add_search,search_data)
                    counter += 1
                    print("holy fuck I worked")

                except:
                    print("i have failed")


        w = walmart.mkWalmart(search)
        for i in w:
            counterTotal += 1
            if self.findDuplicate(i,search) == 1:
                print("i'm in here all ready")
            else:
                print("i'm here to stay bitches")
                lst.append(i)
                try:
                    food_data = (i.n, float(i.p), float(i.w), "walmart")
                    self.cursor.execute(add_food,food_data)
                    foodID = self.cursor.lastrowid
                    search_data = (foodID, search, 0)
                    self.cursor.execute(add_search, search_data)
                    self.database.commit()
                    print(i.n)
                    counter += 1;
                except:
                    print("i have failed")
        try:
            add_searchs = ("INSERT INTO search "
                        "(name, popularity)"
                        "VALUE (%s, %s)")
            self.cursor.execute(add_searchs, (search, 0))
            self.database.commit()
        except:
            print("boo")
        # cursor.close()
        # database.close
        print(counter)
        print(counterTotal)
        try:
            for i in lst:
                print(i.n)
        except:
            print("it couldn't fucking print!")
开发者ID:crumudgin,项目名称:grocer,代码行数:92,代码来源:main.py


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