---
name: "mongoc_client_get_database"
section: "3"
platform: "linux"
package: "libmongoc-doc"
version: "1.30.4-1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/mongoc_client_get_database"
---

# mongoc\_client\_get\_database(3)

## SYNOPSIS

```
mongoc_database_t *
mongoc_client_get_database (mongoc_client_t *client,
                            const char *name);
```

Get a newly allocated *mongoc\_database\_t* for the database named **name**.

**TIP:**

Databases are automatically created on the MongoDB server upon insertion of the first document into a collection. There is no need to create a database manually.

## PARAMETERS

- •

  **client**: A *mongoc\_client\_t*.

- •

  **name**: The name of the database.

## RETURNS

A newly allocated *mongoc\_database\_t* that should be freed with *mongoc\_database\_destroy()* when no longer in use.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
