# amfelt import

Create a data contract for a given source.

Creates a data contract for a source identified by a connection string (URL).
Supported URLs are of the form:
protocol+transport://user:pass@host/dbname?opt1=a&opt2=b
protocol:/path/to/file

Supported URL components:
protocol:  name of the driver.
transport: either 'tcp', 'udp', 'unix' or driver name (odbc/oleodbc).
dbname*:   database, instance, or service name/ID to connect to.
?opt1=...: additional database driver options.

* For Microsoft SQL Server, /dbname can be /instance/dbname, where /instance is
optional. For Oracle Database, /dbname is of the form /service/dbname where
/service is the service name or SID, and /dbname is optional.

The contract is saved as contracts/`<name>`.odcs.yaml next to the project file,
the file commit pushes with amfelt.yaml. `--folder` saves it in another directory
instead, and commit then refuses the project until the file is moved to
contracts/.

Connecting to the source and reading its schema must finish within the import
timeout, 2m by default. Set the AMFELT_IMPORT_TIMEOUT environment variable to a
Go duration, such as 10m or 1h, to change it. An unset, invalid or non-positive
value uses the default.

## Usage

```text
amfelt import [name] [connection url] [flags]
```

## Examples

```text
import adventureworks postgres://localhost:5432/Adventureworks?sslmode=disable
Imports the AdventureWorks database from a local Postgres database on port 5432.

import localfile sqlite:/localfile.db?loc=auto --force
Imports a local SQLite file. Existing project files and data contracts are
overwritten.
```

## Flags

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| `--abbreviation` | `string` | — | short source identifier for DWH naming convention (e.g. 'adw' for adventureworks) |
| `--annotated` | `bool` | `false` | include detailed type annotations (precision, scale, timezone, etc.) in the contract |
| `--folder` | `string` | `contracts` | directory to save the contract in, relative to the project file (commit pushes only contracts/) |
| `--force` | `bool` | `false` | ignore warnings and errors |
| `--install` | `bool` | `false` | automatically install the required plugins |
| `--namespace` | `string` | — | source namespace to interact with (comma-separated for multi-schema; 'all' for all schemas) |
| `--path` | `string` | `amfelt.yaml` | path of the Amfelt project file |
| `--schema-abbrev` | `string` | — | explicit schema abbreviations as key=value pairs (e.g. humanresources=hr,production=prod) |
| `--secret-ref` | `string` | — | vault reference path for credentials (e.g. development/database/`<project-id>`/my-db); skips inline credentials |
{.clidoc-flags-table}

## Global flags

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| `--amfelt-dir` | `string` | `.amfelt` | directory for workspace files (such as plugins); does not move agent identity (controlled by AMFELT_DIR) |
| `--config` | `string` | — | directory or filename of the application configuration |
| `-f`, `--format` | `string` | `default` | log format to use; either default, pretty, or json |
| `-l`, `--level` | `string` | `info` | minimum log level to display; either error, warn, info, or debug |
| `-v`, `--verbose` | `bool` | `false` | trigger to use verbose logging |
{.clidoc-flags-table}

---

Generated from `amfelt` v5.6.3.
