Skip to main content

Optional import/export extension for xladmin backend.

Project description

xladmin-import-export backend

Optional backend extension for xladmin that adds import/export endpoints.

Features

  • export json, csv, xlsx
  • import json, csv, xlsx
  • export custom readable fields, including your custom list_display fields
  • import validation before commit
  • PK conflict modes: auto_generate_pk, update_existing, skip_existing
  • UUID primary key auto-generation on import

Install

pip install xladmin xladmin-import-export

Minimal Example

from fastapi import APIRouter
from xladmin import AdminHTTPConfig, create_admin_router
from xladmin_import_export import ImportExportConfig, create_import_export_router

router = APIRouter()
router.include_router(create_admin_router(http_config))
router.include_router(create_import_export_router(http_config))

user_model = ModelConfig(
    model=UserORM, slug="users",
    import_export=ImportExportConfig(),
)

# OR

user_model = ModelConfig(
    model=UserORM, slug="users",
    import_export=ImportExportConfig(
        export_fields=("id", "email", "roles"),
        import_fields=("id", "email", "roles"),
    ),
)

Endpoints

  • GET /xladmin/models/{slug}/import-export/meta/
  • POST /xladmin/models/{slug}/export/
  • POST /xladmin/models/{slug}/import/validate/
  • POST /xladmin/models/{slug}/import/commit/

Development

cd xladmin-backend/xladmin-import-export
uv sync --extra dev
uv run pytest -q
uv run ruff check .
uv run mypy
uv run python -m build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xladmin_import_export-0.1.1.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xladmin_import_export-0.1.1-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file xladmin_import_export-0.1.1.tar.gz.

File metadata

  • Download URL: xladmin_import_export-0.1.1.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for xladmin_import_export-0.1.1.tar.gz
Algorithm Hash digest
SHA256 269ac2011b96a70d891e8dc0c6d74e64814e3705ac7a94f045b716e80d5ac05b
MD5 3f34d2cebd65dab6521ea9ffcb84a588
BLAKE2b-256 4b256cf0695146eeac3e20432ea3e9a777d25e2fa0409d226a648320388c3658

See more details on using hashes here.

File details

Details for the file xladmin_import_export-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for xladmin_import_export-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bfaa7f02b787180a3be453cc8a0bc5afa1a67baa129e93533c4acd7de2f18ee8
MD5 6cbb2c6794270fd37d34087e082523f5
BLAKE2b-256 37d4f1aab1c2ec7a84e201b58fb8752854f0ce4262fbed1ed861c353fa7f76b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page