import hashlib


def _make_stmt_name(func):
    """
    Create the prepared query name which is a string up-to 63 characters made up of
    - an underscore
    - the md5 hash of the <module.function> name
    - an underscore
    - up-to 29 characters of the function name
    """
    m = hashlib.md5()
    func_name = func.__name__
    fully_qualified_name = f"{func.__module__}.{func.__name__}"
    m.update(bytes(fully_qualified_name, encoding="utf-8"))

    stmt_name = "_"
    stmt_name += m.hexdigest()
    stmt_name += "_" + func_name[:29]
    return stmt_name