當前位置: 首頁>>代碼示例>>Python>>正文


Python DB.add_item方法代碼示例

本文整理匯總了Python中db.DB.add_item方法的典型用法代碼示例。如果您正苦於以下問題:Python DB.add_item方法的具體用法?Python DB.add_item怎麽用?Python DB.add_item使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在db.DB的用法示例。


在下文中一共展示了DB.add_item方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: add_congregation

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import add_item [as 別名]
    def add_congregation(self):
        """
        Prepares user entered data for a new congregation before sending it to
        the db module for insertion into the database.
        """

        values = (self.name,
                  self.phone,
                  self.email,
                  self.street,
                  self.city,
                  self.state,
                  self.zip,
                  self.week,
                  self.time,
                  self.long,
                  self.lat,
                  self.note,
                  self.visibility)

        # REVIEW long and lat: Leading zeros may be removed.

        dup_congregation = Congregation.__check_for_dup(self, values[0])
        missing_fields = Congregation.__check_required_fields(self)

        if dup_congregation == "Passed" and missing_fields == "Passed":
            DB.add_item(None, 'Congregation', Congregation.columns, values)
        else:
            if dup_congregation != "Passed":
                print("A duplicate entry was found: {}".format(
                    dup_congregation[1]))
            else:
                print("A required field was missing: {}".format(
                    missing_fields[1]))
開發者ID:TheoDevelopers,項目名稱:pyTalkManager,代碼行數:36,代碼來源:congregation.py

示例2: add_brother

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import add_item [as 別名]
    def add_brother(self):
        """
        Adds a new brother to the database.

        :return:
        """

        values = (self.first_name,
                  self.middle_name,
                  self.last_name,
                  self.email,
                  self.phone,
                  self.congregation,
                  self.responsibility,
                  self.speaker,
                  self.chairman,
                  self.coordinator,
                  self.note,
                  self.visibility)

        missing_fields = Brother.__check_required_fields(self)

        if missing_fields == "Passed":
            DB.add_item(None, 'Brother', Brother.columns, values)
        else:
            print("The following are missing: ", missing_fields)
開發者ID:TheoDevelopers,項目名稱:pyTalkManager,代碼行數:28,代碼來源:brother.py

示例3: add_outline

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import add_item [as 別名]
    def add_outline(self, number, title):
        """
        Sends content received to be added to the database.
        """

        check = self.check_sanity(number, title) 
        if check[0] == 'True':
            DB.add_item(self,'Talk', ('number', 'title', 'visibility'), (number, title, 'True'))
            return ('True',) 
           
        else:
          return check 
開發者ID:TheoDevelopers,項目名稱:pyTalkManager,代碼行數:14,代碼來源:outline.py

示例4: import_file

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import add_item [as 別名]
    def import_file(self):
        """
        Method that allows the user to import outlines from a file.

        :return: None
        """

        import_file = QtGui.QFileDialog.getOpenFileName(None, "Open Outline "
                                                              "", None,
                                                        "Outline File (*.txt)")

        self.outline_number = []
        self.outline_title = []

        with open(import_file[0], 'r') as text:
            for line in text:
                split = line.find(':')
                self.outline_number.append(line[:split])

                # Replace single quotes (') with double single ('') quotes so
                # that single quotes can be passed as a quarry to SQLite.
                # For example: "We''ll know John''s ..."
                self.outline_title.append(line[split + 1:-1].replace("'", "''"))

        list_size = len(self.outline_title)
        values = ""
        for i in range(len(self.outline_title)):  # Create the SQL quarry
            values = "{VALUES}, ('{NUMBER}' , '{TITLE}', 'True')".format(
                                                  VALUES=values,
                                                  NUMBER=self.outline_number[i],
                                                  TITLE=self.outline_title[i])

        db = DB()
        columns = ('number', 'title', 'visibility')
        values = values[2:]  # Remove the first ',' from values
        db.add_item('Talk', columns, values)
        self.populate_list()
開發者ID:TheoDevelopers,項目名稱:pyTalkManager,代碼行數:39,代碼來源:main.py


注:本文中的db.DB.add_item方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。