Metadata-Version: 2.3
Name: plexosdb
Version: 1.4.1
Summary: SQLite API for plexos XMLs
Keywords: PLEXOS,Database,SQLite
Author: Pedro Andres Sanchez Perez, Kodi Obika, mcllerena
Author-email: Pedro Andres Sanchez Perez <psanchez@nrel.gov>, Kodi Obika <kodi.obika@nrel.gov>, mcllerena <mcllerena@users.noreply.github.com>
License: BSD 3-Clause License
         
         Copyright (c) 2024, Alliance for Sustainable Energy LLC, All rights reserved.
         
         Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
         
         * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
         
         * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
         
         * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
         
         THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Topic :: Software Development :: Build Tools
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Database
Classifier: Typing :: Typed
Requires-Dist: loguru
Maintainer: Pedro Andres Sanchez Perez, Kodi Obika, mcllerena
Maintainer-email: Pedro Andres Sanchez Perez <psanchez@nrel.gov>, Kodi Obika <kodi.obika@nrel.gov>, mcllerena <mcllerena@users.noreply.github.com>
Requires-Python: >=3.11, <3.15
Project-URL: Changelog, https://github.com/NatLabRockies/plexosdb/blob/main/CHANGELOG.md
Project-URL: Documentation, https://natlabrockies.github.io/plexosdb/
Project-URL: Issues, https://github.com/NatLabRockies/plexosdb/issues
Project-URL: Source, https://github.com/NatLabRockies/plexosdb
Description-Content-Type: text/markdown

### plexosdb

> SQLite-backed Python API for reading, building, and writing PLEXOS XML models
>
> [![image](https://img.shields.io/pypi/v/plexosdb.svg)](https://pypi.python.org/pypi/plexosdb)
> [![image](https://img.shields.io/pypi/l/plexosdb.svg)](https://pypi.python.org/pypi/plexosdb)
> [![image](https://img.shields.io/pypi/pyversions/plexosdb.svg)](https://pypi.python.org/pypi/plexosdb)
> [![CI](https://github.com/NatLabRockies/plexosdb/actions/workflows/CI.yaml/badge.svg)](https://github.com/NatLabRockies/plexosdb/actions/workflows/CI.yaml)
> [![codecov](https://codecov.io/gh/NatLabRockies/plexosdb/branch/main/graph/badge.svg)](https://codecov.io/gh/NatLabRockies/plexosdb)
> [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
> [![Documentation](https://github.com/NatLabRockies/plexosdb/actions/workflows/docs.yaml/badge.svg?branch=main)](https://natlabrockies.github.io/plexosdb/)

plexosdb converts PLEXOS XML input files into an in-memory SQLite database,
giving you a fast, typed Python API to query, create, and modify power system
models programmatically, then write them back to XML.

## Installation

```console
pip install plexosdb
```

Or with [uv](https://docs.astral.sh/uv/):

```console
uv add plexosdb
```

**Python version support:** 3.11, 3.12, 3.13, 3.14

## Quick Start

```python
from plexosdb import PlexosDB, ClassEnum, CollectionEnum

# Load a PLEXOS XML file into an in-memory SQLite database
db = PlexosDB.from_xml("model.xml")

# Query existing objects
generators = db.get_object_names(ClassEnum.Generator)

# Add new objects
db.add_object(ClassEnum.Generator, name="SolarPV_01", category="Renewables")
db.add_object(ClassEnum.Node, name="Bus_1")

# Create memberships between objects
db.add_membership(
    CollectionEnum.GeneratorNodes,
    parent_class=ClassEnum.Generator,
    parent_name="SolarPV_01",
    child_class=ClassEnum.Node,
    child_name="Bus_1",
)

# Export the modified model back to XML
db.to_xml("modified_model.xml")
```

## Documentation

Full documentation is available at
[natlabrockies.github.io/plexosdb](https://natlabrockies.github.io/plexosdb/).

## Developer Setup

plexosdb uses [uv](https://docs.astral.sh/uv/) for dependency management.

```console
git clone https://github.com/NatLabRockies/plexosdb.git
cd plexosdb
uv sync --all-groups
```

Install the git hooks so your code is checked before making commits:

```console
uv run prek install
```

Run the test suite:

```console
uv run pytest
```

## License

This software is released under a BSD-3-Clause
[License](https://github.com/NatLabRockies/plexosdb/blob/main/LICENSE.txt).

This software was developed under software record SWR-24-90 at the National
Renewable Energy Laboratory ([NREL](https://www.nrel.gov)).

## Disclaimer

PLEXOS is a registered trademark of Energy Exemplar Pty Ltd. Energy Exemplar Pty
Ltd. has no affiliation to or participation in this software. Reference herein
to any specific commercial products, process, or service by trade name,
trademark, manufacturer, or otherwise, does not necessarily constitute or imply
its endorsement, recommendation, or favoring by the United States Government or
Alliance for Sustainable Energy, LLC ("Alliance"). The views and opinions of
authors expressed in the available or referenced documents do not necessarily
state or reflect those of the United States Government or Alliance.
