# dap initdb

The `dap initdb` command automatically fetches the schema and data from DAP, connects to your specified database, creates the necessary table based on the schema, and inserts the data into the table. This process simplifies the initialization of a database with DAP data.

{% hint style="warning" %}
**Type juggling is not supported.** The data types specified in the schema from the DAP API must be strictly followed during table creation and data insertion.
{% endhint %}

### Usage

```
dap [arguments] initdb [flags]
```

### Options

**`--namespace <string>`**\
Specifies the data source (namespace). Available options: {canvas, canvas\_logs, catalog, new\_quizzes}.

**`--table <string>`**\
Specifies the table(s) to fetch data from. Can be a single table name, a comma separated list of table names or the special `all` keyword to fetch all tables in the namespace.

### Global Options

**`--client-id <string>`**\
Client ID obtained from the Identity Service. Skip, if `DAP_CLIENT_ID` environment variable is set.

**`--client-secret <string>`**\
Client Secret obtained from the Identity Service. Skip, if `DAP_CLIENT_SECRET` environment variable is set.

**`--connection-string <string>`**\
The connection string used to connect to the target database. It must follow RFC 3986 format:\
`dialect://username:password@host:port/database`. Skip, if `DAP_CONNECTION_STRING` environment variable is set.

**`-h, --help`**\
Displays help information for the command.

### Examples

Get a snapshot of the `courses` and `users` tables from the `canvas` namespace and insert into your database:\
`$ dap initdb --namespace canvas --table courses,users`

Example with all tables in the namespace and the connection string defined in the command:\
`$dap initdb --namespace canvas --table all --connection-string postgresql://scott:password@server.example.com/testdb`

### Related Resources

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Key Concepts</strong></td><td>Get familiar with the key concepts in DAP.</td><td><a href="../../key-concepts">key-concepts</a></td></tr><tr><td><strong>Rate Limits &#x26; Policies</strong></td><td>Learn more about the limits and our policies in DAP.</td><td><a href="../../limits-policies">limits-policies</a></td></tr><tr><td><strong>Datasets</strong></td><td>Discover the available namespaces and tables.</td><td><a href="../../dataset">dataset</a></td></tr></tbody></table>
