How to use the aiosql.aiosql.SQLOperationType function in aiosql

To help you get started, we’ve selected a few aiosql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nackjicholson / aiosql / aiosql / aiosql.py View on Github external
def ctx_mgr(conn, *args, **kwargs):
        parameters = kwargs if len(kwargs) > 0 else args
        return driver_adapter.select_cursor(conn, query_name, sql, parameters)

    ctx_mgr.__name__ = ctx_mgr_method_name
    ctx_mgr.__doc__ = docs
    ctx_mgr.sql = sql

    if getattr(driver_adapter, "is_aio_driver", False):
        if op_type == SQLOperationType.SELECT:
            return [(query_name, aio_fn), (ctx_mgr_method_name, ctx_mgr)]
        else:
            return [(query_name, aio_fn)]
    else:
        if op_type == SQLOperationType.SELECT:
            return [(query_name, fn), (ctx_mgr_method_name, ctx_mgr)]
        else:
            return [(query_name, fn)]
github nackjicholson / aiosql / aiosql / aiosql.py View on Github external
def fn(conn, *args, **kwargs):
        parameters = kwargs if len(kwargs) > 0 else args
        if op_type == SQLOperationType.INSERT_RETURNING:
            return driver_adapter.insert_returning(conn, query_name, sql, parameters)
        elif op_type == SQLOperationType.INSERT_UPDATE_DELETE:
            return driver_adapter.insert_update_delete(conn, query_name, sql, parameters)
        elif op_type == SQLOperationType.INSERT_UPDATE_DELETE_MANY:
            return driver_adapter.insert_update_delete_many(conn, query_name, sql, *parameters)
        elif op_type == SQLOperationType.SCRIPT:
            return driver_adapter.execute_script(conn, sql)
        elif op_type == SQLOperationType.SELECT:
            return driver_adapter.select(conn, query_name, sql, parameters)
        else:
            raise ValueError(f"Unknown op_type: {op_type}")
github nackjicholson / aiosql / aiosql / aiosql.py View on Github external
def fn(conn, *args, **kwargs):
        parameters = kwargs if len(kwargs) > 0 else args
        if op_type == SQLOperationType.INSERT_RETURNING:
            return driver_adapter.insert_returning(conn, query_name, sql, parameters)
        elif op_type == SQLOperationType.INSERT_UPDATE_DELETE:
            return driver_adapter.insert_update_delete(conn, query_name, sql, parameters)
        elif op_type == SQLOperationType.INSERT_UPDATE_DELETE_MANY:
            return driver_adapter.insert_update_delete_many(conn, query_name, sql, *parameters)
        elif op_type == SQLOperationType.SCRIPT:
            return driver_adapter.execute_script(conn, sql)
        elif op_type == SQLOperationType.SELECT:
            return driver_adapter.select(conn, query_name, sql, parameters)
        else:
            raise ValueError(f"Unknown op_type: {op_type}")