Metadata-Version: 2.1
Name: sqlalchemy-model-builder
Version: 0.2.0
Summary: SQLAlchemy Model Builder
Project-URL: Documentation, https://github.com/aminalaee/sqlalchemy-model-builder
Project-URL: Issues, https://github.com/aminalaee/sqlalchemy-model-builder/issues
Project-URL: Source, https://github.com/aminalaee/sqlalchemy-model-builder
Author-email: Amin Alaee <me@aminalaee.dev>
License-Expression: MIT
License-File: LICENSE
Keywords: sqlalchemy,testing
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.7
Requires-Dist: sqlalchemy>=1.4
Description-Content-Type: text/markdown

# SQLAlchemy Model Builder
![test](https://github.com/aminalaee/sqlalchemy-model-builder/actions/workflows/test.yml/badge.svg) ![publish](https://github.com/aminalaee/sqlalchemy-model-builder/actions/workflows/publish.yml/badge.svg) [![codecov](https://codecov.io/gh/aminalaee/sqlalchemy-model-builder/branch/main/graph/badge.svg?token=QOLK6R9M52)](https://codecov.io/gh/aminalaee/sqlalchemy-model-builder) 
[![pypi](https://img.shields.io/pypi/v/sqlalchemy-model-builder?color=%2334D058&label=pypi)](https://pypi.org/project/sqlalchemy-model-builder/)

## Features
- Build SQLAlchemy model instance with random data
- Save SQLAlchemy model instance with random data
- Build relationships
- Build minimal (with required fields) only

---

## Installation

```shell
$ pip install sqladmin
```

---

## How to use
Deinfe the SQLAlchemy models:

```python
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.sql.sqltypes import Integer, String, Text

Base = declarative_base()


class Address(Base):
    __tablename__ = "addresses"

    id = Column(Integer, primary_key=True)
    user_id = Column(Integer, ForeignKey("users.id"))
    user = relationship("User", back_populates="addresses")


class User(Base):
    __tablename__ = "users"

    addresses = relationship("Address", back_populates="user")
    bio = Column(Text)
    id = Column(Integer, primary_key=True)
    name = Column(String, nullable=False)

```

Save random model instance:

```python
from sqlalchemy_model_builder import ModelBuilder

random_user = ModelBuilder(User).save(db)
```

Build random model without saving:

```python
random_user = ModelBuilder(User).build()
```

Build minimal model instance:

```python
minimal_random_user = ModelBuilder(User, minimal=True).build()
```

Build or save with specific values:

```python
random_address = ModelBuilder(Address).build(user_id=1)
```

---

## Supported Data Types
- BigInteger
- Boolean
- Date
- DateTime
- Enum
- Float
- Integer
- Interval
- LargeBinary
- MatchType (Todo)
- Numeric
- PickleType (Todo)
- SchemaType (Todo)
- SmallInteger
- String
- Text
- Time
- Unicode
- UnicodeText
