~homeworkprod/byceps

ref: 6083c64abf465c011eb6b8963e0fd7d010da0d58 byceps/byceps/database.py -rw-r--r-- 563 bytes
6083c64a — Jochen Kupperschmidt Pre-select bank transfer as the default payment method for orders in the mark-as-paid form 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
byceps.database
~~~~~~~~~~~~~~~

Database utilities.

:Copyright: 2006-2017 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

import uuid

from flask_sqlalchemy import BaseQuery, SQLAlchemy
from sqlalchemy.dialects.postgresql import JSONB, UUID


db = SQLAlchemy(session_options={'autoflush': False})


db.JSONB = JSONB


class Uuid(UUID):

    def __init__(self):
        super().__init__(as_uuid=True)


db.Uuid = Uuid


def generate_uuid():
    """Generate a random UUID (Universally Unique IDentifier)."""
    return uuid.uuid4()