docs: def calc_blr(xsqlda):
      "Calculate  BLR from XSQLVAR array."
      ln = len(xsqlda) * 2
      blr = [5, 2, 4, 0, ln & 255, ln >> 8]
      for x in xsqlda:
          sqltype = x.sqltype
          if sqltype == SQL_TYPE_VARYING:
              blr += [37, x.sqllen & 255, x.sqllen >> 8]
          elif sqltype == SQL_TYPE_TEXT:
              blr += [14, x.sqllen & 255, x.sqllen >> 8]
          elif sqltype == SQL_TYPE_LONG:
              blr += [8, x.sqlscale]
          elif sqltype == SQL_TYPE_SHORT:
              blr += [7, x.sqlscale]
          elif sqltype == SQL_TYPE_INT64:
              blr += [16, x.sqlscale]
          elif sqltype == SQL_TYPE_QUAD:
              blr += [9, x.sqlscale]
          elif sqltype == SQL_TYPE_DEC_FIXED:
              blr += [26, x.sqlscale]
          else:
              blr += sqltype2blr[sqltype]
          blr += [7, 0]   # [blr_short, 0]
      blr += [255, 76]    # [blr_end, blr_eoc]
  
      # x.sqlscale value shoud be negative, so b convert to range(0, 256)
      return bs(256 + b if b < 0 else b for b in blr)