Skip to main content

SQLAlchemy Model Builder

Project description

SQLAlchemy Model Builder

test publish codecov pypi

Features

  • Build and Save SQLALchemy models with random data
  • Build relationships (Todo)
  • Build with minimal (required) fields only (Todo)

How to use

Build SQLAlchemy model:

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

from sqlalchemy_model_builder import ModelBuilder

Base = declarative_base()


class User(Base):
    __tablename__ = "users"

    id = Column(Integer, primary_key=True)
    name = Column(String)


random_user = ModelBuilder(User).build()  # Note: This will not insert the User

Save SQLAlchemy model:

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

from sqlalchemy_model_builder import ModelBuilder

Base = declarative_base()

engine = create_engine("sqlite://", echo=True)


class User(Base):
    __tablename__ = "users"

    bio = Column(Text)
    id = Column(Integer, primary_key=True)
    name = Column(String)


Base.metadata.create_all(engine)

LocalSession = sessionmaker(bind=engine)

db = LocalSession()


random_user = ModelBuilder(User).save(db=db)  # Note: Builds and Saves model using provided session

Supported Data Types

  • BigInteger
  • Boolean
  • Date
  • DateTime
  • Enum (Todo)
  • Float
  • Integer
  • Interval
  • LargeBinary (Todo)
  • MatchType (Todo)
  • Numeric (Todo)
  • 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

sqlalchemy-model-builder-0.0.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file sqlalchemy-model-builder-0.0.2.tar.gz.

File metadata

  • Download URL: sqlalchemy-model-builder-0.0.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0a1 CPython/3.8.10 Linux/5.4.0-1047-azure

File hashes

Hashes for sqlalchemy-model-builder-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b81fe4df4447777ff53cb0d559d30d036f9f0f3889d4bbe6eef50971beb1fcc9
MD5 e5a3c664f2e60e55f25269fd47ca2e7b
BLAKE2b-256 e72d14cacd3306398f5f3b8603183b20ccbed4c0d7b967b051596c88ff129c94

See more details on using hashes here.

File details

Details for the file sqlalchemy_model_builder-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for sqlalchemy_model_builder-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 72f256efa63ffcb8c5cb070eb4d9b68a4775f7cc4b96fed63b6f714161c9f1c7
MD5 6ed4cbd2f900557d95c4cb88a8aa7699
BLAKE2b-256 1922ff2305ad86942b9680f666daee52f64931117523a41a1beac78d0fa2a165

See more details on using hashes here.

Supported by

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