SQLAlchemy Model Builder
Project description
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
$ pip install sqlalchemy-model-builder
How to use
Deinfe the SQLAlchemy models:
from sqlalchemy import Integer, String, Text
from sqlalchemy.ext.declarative import declarative_base
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:
from sqlalchemy_model_builder import ModelBuilder
random_user = ModelBuilder(User).save(db)
Build random model without saving:
random_user = ModelBuilder(User).build()
Build minimal model instance:
minimal_random_user = ModelBuilder(User, minimal=True).build()
Build or save with specific values:
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
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
Built Distribution
File details
Details for the file sqlalchemy_model_builder-0.3.0.tar.gz
.
File metadata
- Download URL: sqlalchemy_model_builder-0.3.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.24.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4230c18cb1c723197b363cd8af1f127a4d4e971021288653f1fd726718e9f2da |
|
MD5 | d7d225a9ecbb371f3f4d632f8bcee480 |
|
BLAKE2b-256 | 3134cbd275403ce60394e835eac0490b252f6c0e8b33bd35480c78e19c3a9815 |
File details
Details for the file sqlalchemy_model_builder-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: sqlalchemy_model_builder-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.24.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b578086b97211340e18686a806cff71ab04f99c00d17db2830b248557f3170f2 |
|
MD5 | 0d7fa50155bd6874e9d379c538272002 |
|
BLAKE2b-256 | 82e5bb2f0bcff60645f67f75f24a1455ed4e24c588e42288f47f3119df09cf14 |