lamindb.setup

Setup & configure LaminDB.

Many functions in this “setup API” have a matching command in the CLI CLI.

Guide: Install & setup.

Basic operations

lamindb.setup.login(user=None, *, api_key=None, **kwargs)

Log into LaminHub.

login() prompts for your API key unless you set it via the LAMIN_API_KEY environment variable or pass it as an argument.

You can create your API key in your account settings on LaminHub (top right corner).

Parameters:
  • user (str | None, default: None) – User handle.

  • api_key (str | None, default: None) – API key.

Return type:

UserSettings

See also

Login via the CLI command lamin login, see here.

Examples

Logging in the first time:

import lamindb as ln

ln.setup.login()  # prompts for API key

After authenticating multiple users, you can switch between user profiles:

ln.setup.login("myhandle")  # pass your user handle
lamindb.setup.logout()

Log out the current user.

This deletes the ~/.lamin/current_user.env so that you’ll no longer be automatically authenticated in the environment.

It keeps a copy as ~/.lamin/user--<user_handle>.env so you can easily switch between user profiles.

See also

Logout via the CLI command lamin logout, see here.

lamindb.setup.init(*, storage='.', name=None, db=None, modules=None, **kwargs)

Init a LaminDB instance.

Parameters:
  • storage (lamindb.core.types.UPathStr, default: '.') – A local or remote folder ('s3://...' or 'gs://...'). Defaults to current working directory.

  • name (str | None, default: None) – Instance name. If not passed, it will equal the folder name passed to storage.

  • db (PostgresDsn | None, default: None) – Database connection URL. Defaults to None, which implies an SQLite file in the storage location.

  • modules (str | None, default: None) – Comma-separated string of schema modules.

  • **kwargs – Keyword arguments for low-level control.

Return type:

None

See also

Init an instance for via the CLI, see here.

lamindb.setup.disconnect(mute=False)

Clear default instance configuration.

Returns None if succeeds, otherwise an exception is raised. :rtype: None

See also

Clear default instance configuration via the CLI, see here.

lamindb.setup.delete(slug, force=False, require_empty=True)

Delete a LaminDB instance.

Parameters:
  • slug (str) – The instance slug account_handle/instance_name or URL. If the instance is owned by you, it suffices to pass the instance name.

  • force (bool, default: False) – Whether to skip the confirmation prompt.

  • require_empty (bool, default: True) – Whether to check if the instance is empty before deleting.

Return type:

int | None

See also

Delete an instance via the CLI, see here.

Modules & settings

settings

Global SetupSettings.

core

Core setup library.

django(command[, package_name])

Call Django commands.

errors

Errors.

types

Types.

Migration management

migrate()

Manage database migrations.