How to use the aiosql.types.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 / queries.py View on Github external
async def fn(self, conn, *args, **kwargs):
            parameters = kwargs if len(kwargs) > 0 else args
            if operation_type == SQLOperationType.INSERT_RETURNING:
                return await self.driver_adapter.insert_returning(conn, query_name, sql, parameters)
            elif operation_type == SQLOperationType.INSERT_UPDATE_DELETE:
                return await self.driver_adapter.insert_update_delete(
                    conn, query_name, sql, parameters
                )
            elif operation_type == SQLOperationType.INSERT_UPDATE_DELETE_MANY:
                return await self.driver_adapter.insert_update_delete_many(
                    conn, query_name, sql, *parameters
                )
            elif operation_type == SQLOperationType.SCRIPT:
                return await self.driver_adapter.execute_script(conn, sql)
            elif operation_type == SQLOperationType.SELECT:
                return await self.driver_adapter.select(
                    conn, query_name, sql, parameters, record_class
                )
            elif operation_type == SQLOperationType.SELECT_ONE:
github nackjicholson / aiosql / aiosql / queries.py View on Github external
fn.__name__ = query_name
    fn.__doc__ = doc_comments
    fn.sql = sql

    ctx_mgr_method_name = f"{query_name}_cursor"

    def ctx_mgr(self, conn, *args, **kwargs):
        parameters = kwargs if len(kwargs) > 0 else args
        return self.driver_adapter.select_cursor(conn, query_name, sql, parameters)

    ctx_mgr.__name__ = ctx_mgr_method_name
    ctx_mgr.__doc__ = doc_comments
    ctx_mgr.sql = sql

    if operation_type == SQLOperationType.SELECT:
        return [(query_name, fn), (ctx_mgr_method_name, ctx_mgr)]
    else:
        return [(query_name, fn)]