Ejemplo n.º 1
0
def init_db(conn: Connection) -> None:
    add_functions(conn)
    conn.create_function("X_SIMILARITY",
                         narg=3,
                         func=quick_ratio,
                         deterministic=True)
    conn.create_function("X_NORM_CASE",
                         narg=1,
                         func=normcase,
                         deterministic=True)
    conn.create_aggregate("X_QUANTILES",
                          n_arg=-1,
                          aggregate_class=cast(Any, _Quantiles))
Ejemplo n.º 2
0
def add_functions(conn: Connection) -> None:
    conn.row_factory = Row
    conn.create_collation("X_COLLATION", strcoll)
    conn.create_function("X_STRXFRM", narg=1, func=strxfrm, deterministic=True)
    conn.create_function("X_NORMALIZE",
                         narg=1,
                         func=_normalize,
                         deterministic=True)
    conn.create_function("X_LOWER", narg=1, func=_lower, deterministic=True)
    conn.create_function("X_UUID_B",
                         narg=0,
                         func=_uuid_bytes,
                         deterministic=False)