Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shosca/sqlalchemy-hilo
HiLo generators for SQLAlchemy
https://github.com/shosca/sqlalchemy-hilo
Last synced: 8 days ago
JSON representation
HiLo generators for SQLAlchemy
- Host: GitHub
- URL: https://github.com/shosca/sqlalchemy-hilo
- Owner: shosca
- License: other
- Created: 2016-11-14T13:38:53.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-19T23:45:06.000Z (almost 8 years ago)
- Last Synced: 2024-09-23T06:36:29.882Z (about 2 months ago)
- Language: Python
- Homepage:
- Size: 3.91 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
SQLAlchemy HiLo PK Generator
============================There are two flavors of the HiLo generator, ``HiLoGenerator`` and
``RowPerTableHiLoGenerator``. ``HiLoGenerator`` will create a single
column table to keep track of the ``hi`` value:.. code:: sql
CREATE TABLE single_hilo (
next_hi BIGINT NOT NULL
)``RowPerTableHiLoGenerator`` will create a two column table to keep
track of the ``hi`` value per table per row:.. code:: sql
CREATE TABLE row_per_table_hilo (
table_name VARCHAR(255) NOT NULL,
next_hi BIGINT NOT NULL,
PRIMARY KEY (table_name)
)You can use them in your models like any other ``Sequence``:
.. code:: python
class Entity(Base):
id = Column(BigInteger(), HiLoGenerator(), primary_key=True)
...or
.. code:: python
class Entity(Base):
id = Column(BigInteger(), RowPerTableHiLoGenerator(), primary_key=True)
...