concept record in category python

appears as: records, record, records
Practices of the Python Pro

This is an excerpt from Manning's book Practices of the Python Pro.

Integration tests may take significantly longer to execute than unit tests. They generally do more than execute some functions and check the output; they might use a database to create and manipulate records, as an example. The interaction being tested is more complex, so the time required to carry it out can grow. For these reasons, integration tests are usually fewer in number than unit tests.

  • Adding or deleting a record
  • Listing the records in a table
  • Selecting and sorting records from a table based on some criteria
  • Counting the number of records in a table
  • Listing 6.3. Adding a record to a SQLite table
    def add(self, table_name, data):
            placeholders = ', '.join('?' * len(data))
            column_names = ', '.join(data.keys())        #1
            column_values = tuple(data.values())         #2
    
            self._execute(
                f'''
                INSERT INTO {table_name}
                ({column_names})
                VALUES ({placeholders});
                ''',
                column_values,                           #3
            )