Metadata-Version: 2.0
Name: SQLAlchemy-Enum34
Version: 1.0.1
Summary: SQLAlchemy type to store standard enum.Enum value
Home-page: https://github.com/spoqa/sqlalchemy-enum34
Author: Hong Minhee
Author-email: hongminhee@member.fsf.org
License: MIT License
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Python :: Implementation :: Stackless
Classifier: Programming Language :: SQL
Classifier: Topic :: Database :: Front-Ends
Classifier: Topic :: Software Development
Requires-Dist: setuptools
Requires-Dist: SQLAlchemy (>=0.8.0)
Requires-Dist: enum34; python_version=='2.5'
Requires-Dist: enum34; python_version=='2.6'
Requires-Dist: enum34; python_version=='2.7'
Requires-Dist: enum34; python_version=='3.2'
Requires-Dist: enum34; python_version=='3.3'

SQLAlchemy-Enum34
=================

.. image:: https://badge.fury.io/py/SQLAlchemy-Enum34.svg?
   :target: https://pypi.python.org/pypi/SQLAlchemy-Enum34
.. image:: https://travis-ci.org/spoqa/sqlalchemy-enum34.svg?branch=master
   :target: https://travis-ci.org/spoqa/sqlalchemy-enum34
.. image:: https://codecov.io/github/spoqa/sqlalchemy-enum34/coverage.svg?branch=master
   :target: https://codecov.io/github/spoqa/sqlalchemy-enum34?branch=master

This package provides a SQLAlchemy type to store values of standard
``enum.Enum`` (which became a part of standard library since Python 3.4).
Its internal representation is equivalent to SQLAlchemy's built-in
``sqlalchemy.types.Enum``, but its Python representation is not
a ``str`` but ``enum.Enum``.

Note that this works on Python 2.6 as well as 3.4, the latest version of
Python, through enum34_ package.

The following example shows how enum_-typed columns can be declared::

    import enum

    from sqlalchemy import Column, Integer
    from sqlalchemy.ext.declarative import declarative_base
    from sqlalchemy_enum34 import EnumType

    Base = declarative_base()

    class Color(enum.Enum):
        black = 'black'
        white = 'white'
        navy = 'navy'
        red = 'red'

    class Size(enum.Enum):
        small = 'S'
        medium = 'M'
        large = 'L'
        xlarge = 'XL'

    class Shirt(Base):
        id = Column(Integer, primary_key=True)
        color = Column(EnumType(Color), nullable=False)
        size = Column(EnumType(Size, name='shirt_size'), nullable=False)

And the following REPL session shows how these columns work:

>>> shirt = session.query(Shirt).filter(Shift.color == Color.navy).first()
>>> shirt.color
<Color.navy: 'navy'>
>>> shirt.size
<Size.large: 'large'>

Written by `Hong Minhee`_ at Spoqa_, and distributed under MIT license.

.. _enum34: https://pypi.python.org/pypi/enum34
.. _enum: https://docs.python.org/3/library/enum.html
.. _Hong Minhee: http://hongminhee.org/
.. _Spoqa: http://www.spoqa.com/


Changelog
=========

1.0.1
-----

Released on August 7, 2015.

- Fixed that ``sqlalchemy_enum34.Enum`` didn't allow nullability.
  [`#1`_ by Andrés Moya]

.. _#1: https://github.com/spoqa/sqlalchemy-enum34/pull/1


1.0.0
-----

First version.  Released on July 30, 2015.


