# Lesson 6: Building applications

## [](#_driver_setup)[Driver setup](../6.1-driver-overview/index.md)

*   The official TypeDB Python driver package can be installed with:
    
    ```console
    pip install typedb-driver
    ```
    
*   The following classes must be imported in order to use the Python driver in any codebase:
    
    ```python
    from typedb.driver import TypeDB, Credentials, DriverOptions
    ```
    

## [](#_managing_databases)[Managing databases](../6.2-managing-users-and-databases/index.md)

*   The `TypeDB.driver` method is used to instantiate a new **driver object**.
    
    ```python
    driver: TypeDBDriver = TypeDB.driver(ADDRESS, credentials, options)
    ```
    
*   The `TypeDBDriver.databases.create` method is used to create a new database.
    
    ```python
    driver.databases.create(DB)
    ```
    

## [](#_transactions)[Transactions](../6.3-transactions/index.md)

*   The `TypeDBSession.transaction` method is used to instantiate a new **transaction**. The **transaction type** is specified using the `READ`, `WRITE`, or `SCHEMA` value of the `TransactionType` enum.
    
    ```python
    transaction: TypeDBTransaction = driver.transaction(DB, TransactionType.READ)
    ```
    
*   Drivers and transaction objects are ideally always be instantiated using a [context manager](https://peps.python.org/pep-0343/) so that their destructors are called automatically, otherwise call \`.close() manually on them
    
    ```python
    with TypeDB.driver(ADDRESS, credentials, options) as driver:
        with session.transaction(DB, TransactionType.READ) as transaction:
            # code goes here
    ```
    
*   The `TypeDBTransaction.commit` method is used to commit a transaction.
    
    ```python
    transaction.commit()
    ```
    

## [](#_executing_queries)[Executing queries](../6.4-executing-queries/index.md)

*   The `TypeDBTransaction.query()` method is used to **submit queries**.
    
    ```python
    results: Promise[QueryAnswer] = transaction.query(QUERY)
    ```
    
*   Typically you submit and resolve the promise catch any errors that are thrown
    
    ```python
    transaction.query(QUERY).resolve()
    ```
    

## [](#_processing_results)[Processing results](../6.5-processing-results/index.md)

*   Each result of a query that ends in `fetch` returns Documents. The top-level dictionary has fields corresponding to the `fetch` clause structure.
    
*   If you know you aren’t catching errors at query time and don’t care about the returned values (such as when doing straight inserts), you can submit without resolving or reading answers to boost performance
    

## [](#_further_learning)Further learning

[Lesson 7: Understanding query patterns](../../7-understanding-query-patterns/index.md)

Learn how to build query patterns utilising advanced elements of TypeQL syntax, and how queries are resolved by TypeDB.

[GRPC Drivers Reference](../../../reference/typedb-grpc-drivers/index.md)

Explore the comprehensive API reference for the official TypeDB GRPC drivers.

[HTTP Drivers Reference](../../../reference/typedb-http-drivers/index.md)

Explore the comprehensive API reference for the official TypeDB HTTP drivers.

[Drivers concepts](../../../core-concepts/drivers/index.md)

Explore the docs for all the official TypeDB drivers, including installation guides, tutorials, and API references.

[Processing results](../6.5-processing-results/index.md) [7\. Understanding query patterns](../../7-understanding-query-patterns/index.md)

[Edit on GitHub](https://github.com/typedb/typedb-docs/edit/3.x-development/academy/modules/ROOT/pages/6-building-applications/summary.adoc) Edit this page on GitHub.