How to use the aiosql.patterns.doc_comment_pattern.match 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
elif query_name.endswith("!"):
        op_type = SQLOperationType.INSERT_UPDATE_DELETE
        query_name = query_name[:-1]
    elif query_name.endswith("#"):
        op_type = SQLOperationType.SCRIPT
        query_name = query_name[:-1]
    else:
        op_type = SQLOperationType.SELECT

    if not valid_query_name_pattern.match(query_name):
        raise SQLParseException(f'name must convert to valid python variable, got "{query_name}".')

    docs = ""
    sql = ""
    for line in lines[1:]:
        match = doc_comment_pattern.match(line)
        if match:
            docs += match.group(1) + "\n"
        else:
            sql += line + "\n"

    docs = docs.strip()
    sql = driver_adapter.process_sql(query_name, op_type, sql.strip())

    return _create_fns(query_name, docs, op_type, sql, driver_adapter)