HiLo primary key generators for sqlalchemy
Project description
# 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:
```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:
```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`:
```python
class Entity(Base):
id = Column(BigInteger(), HiLoGenerator(), primary_key=True)
...
```
or
```python
class Entity(Base):
id = Column(BigInteger(), RowPerTableHiLoGenerator(), primary_key=True)
...
```
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:
```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:
```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`:
```python
class Entity(Base):
id = Column(BigInteger(), HiLoGenerator(), primary_key=True)
...
```
or
```python
class Entity(Base):
id = Column(BigInteger(), RowPerTableHiLoGenerator(), primary_key=True)
...
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sqlalchemy-hilo-0.1.0.tar.gz
(2.7 kB
view hashes)
Built Distribution
Close
Hashes for sqlalchemy_hilo-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2d53b65c916a5ea65bf8ed7a76f525a03fc2067527515b01338af16437c4fa9 |
|
MD5 | 30b8c864593cc6b19986a829ca59c05b |
|
BLAKE2b-256 | d1fc7d19f55d1daf5818af8e8344019a614ead08b2c3fb182f2c3d79da266f49 |