• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python field_types.convert_bind_vars函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中vtdb.field_types.convert_bind_vars函数的典型用法代码示例。如果您正苦于以下问题:Python convert_bind_vars函数的具体用法?Python convert_bind_vars怎么用?Python convert_bind_vars使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了convert_bind_vars函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _create_v2_request_with_keyranges

def _create_v2_request_with_keyranges(
    sql, new_binds, keyspace_name, tablet_type, keyranges, not_in_transaction):
  """Make a request dict from arguments.

  Args:
    sql: Str sql with format tokens.
    new_binds: Dict of bind variables.
    keyspace_name: Str keyspace name.
    tablet_type: Str tablet_type.
    keyranges: A list of keyrange.KeyRange objects.
    not_in_transaction: Bool True if a transaction should not be started
      (generally used when sql is not a write).

  Returns:
    A (str: value) dict.
  """
  sql, new_binds = dbapi.prepare_query_bind_vars(sql, new_binds)
  new_binds = field_types.convert_bind_vars(new_binds)
  req = {
      'Sql': sql,
      'BindVariables': new_binds,
      'Keyspace': keyspace_name,
      'TabletType': topodata_pb2.TabletType.Value(tablet_type.upper()),
      'KeyRanges': keyranges,
      'NotInTransaction': not_in_transaction,
  }
  return req
开发者ID:BobbWu,项目名称:vitess,代码行数:27,代码来源:vtgatev2.py


示例2: _stream_execute

  def _stream_execute(self, sql, bind_variables):
    req = {
      'Query': {
        'Sql': sql,
        'BindVariables': field_types.convert_bind_vars(bind_variables),
        'SessionId': self.session_id,
        'TransactionId': self.transaction_id
      },
      'ImmediateCallerID': {'Username': self.caller_id}
    }

    self._stream_fields = []
    self._stream_conversions = []
    self._stream_result = None
    self._stream_result_index = 0
    try:
      self.client.stream_call('SqlQuery.StreamExecute2', req)
      first_response = self.client.stream_next()
      reply = first_response.reply
      if reply.get('Err'):
        self.__drain_conn_after_streaming_app_error()
        raise gorpc.AppError(reply['Err'].get(
            'Message', 'Missing error message'))

      for field in reply['Fields']:
        self._stream_fields.append((field['Name'], field['Type']))
        self._stream_conversions.append(
            field_types.conversions.get(field['Type']))
    except gorpc.GoRpcError as e:
      self.logger_object.log_private_data(bind_variables)
      raise convert_exception(e, str(self), sql)
    except:
      logging.exception('gorpc low-level error')
      raise
    return None, 0, 0, self._stream_fields
开发者ID:fengshao0907,项目名称:vitess,代码行数:35,代码来源:tablet.py


示例3: _create_v2_request_with_keyspace_ids

def _create_v2_request_with_keyspace_ids(sql, new_binds, keyspace_name, tablet_type, keyspace_ids, not_in_transaction):
    """Make a request dict from arguments.

  Args:
    sql: Str sql with format tokens.
    new_binds: Dict of bind variables.
    keyspace_name: Str keyspace name.
    tablet_type: Str tablet_type.
    keyspace_ids: Bytes list of keyspace IDs.
    not_in_transaction: Bool True if a transaction should not be started
      (generally used when sql is not a write).

  Returns:
    A (str: value) dict.
  """
    # keyspace_ids are Keyspace Ids packed to byte[]
    sql, new_binds = dbapi.prepare_query_bind_vars(sql, new_binds)
    new_binds = field_types.convert_bind_vars(new_binds)
    req = {
        "Sql": sql,
        "BindVariables": new_binds,
        "Keyspace": keyspace_name,
        "TabletType": topodata_pb2.TabletType.Value(tablet_type.upper()),
        "KeyspaceIds": keyspace_ids,
        "NotInTransaction": not_in_transaction,
    }
    return req
开发者ID:shawnps,项目名称:vitess,代码行数:27,代码来源:vtgatev2.py


示例4: _stream_execute2

    def _stream_execute2(self, sql, bind_variables):
        new_binds = field_types.convert_bind_vars(bind_variables)
        query = self._make_req()
        query["Sql"] = sql
        query["BindVariables"] = new_binds
        req = {"Query": query}

        self._stream_fields = []
        self._stream_conversions = []
        self._stream_result = None
        self._stream_result_index = 0
        try:
            self.client.stream_call("SqlQuery.StreamExecute2", req)
            first_response = self.client.stream_next()
            reply = first_response.reply
            if reply.get("Err"):
                self.__drain_conn_after_streaming_app_error()
                raise gorpc.AppError(reply["Err"].get("Message", "Missing error message"))

            for field in reply["Fields"]:
                self._stream_fields.append((field["Name"], field["Type"]))
                self._stream_conversions.append(field_types.conversions.get(field["Type"]))
        except gorpc.GoRpcError as e:
            self.logger_object.log_private_data(bind_variables)
            raise convert_exception(e, str(self), sql)
        except:
            logging.exception("gorpc low-level error")
            raise
        return None, 0, 0, self._stream_fields
开发者ID:yonglehou,项目名称:vitess,代码行数:29,代码来源:tablet.py


示例5: _execute

  def _execute(self, sql, bind_variables):
    req = {
        'QueryRequest': {
            'Sql': sql,
            'BindVariables': field_types.convert_bind_vars(bind_variables),
            'SessionId': self.session_id,
            'TransactionId': self.transaction_id
        },
        'ImmediateCallerID': {'Username': self.caller_id}
    }

    fields = []
    conversions = []
    results = []
    try:
      response = self.rpc_call_and_extract_error('SqlQuery.Execute2', req)
      reply = response.reply

      for field in reply['Fields']:
        fields.append((field['Name'], field['Type']))
        conversions.append(field_types.conversions.get(field['Type']))

      for row in reply['Rows']:
        results.append(tuple(_make_row(row, conversions)))

      rowcount = reply['RowsAffected']
      lastrowid = reply['InsertId']
    except gorpc.GoRpcError as e:
      self.logger_object.log_private_data(bind_variables)
      raise convert_exception(e, str(self), sql)
    except Exception:
      logging.exception('gorpc low-level error')
      raise
    return results, rowcount, lastrowid, fields
开发者ID:kuipertan,项目名称:vitess,代码行数:34,代码来源:tablet.py


示例6: _execute_batch

  def _execute_batch(self, sql_list, bind_variables_list):
    query_list = []
    for sql, bind_vars in zip(sql_list, bind_variables_list):
      req = self._make_req()
      req['Sql'] = sql
      req['BindVariables'] = field_types.convert_bind_vars(bind_vars)
      query_list.append(req)

    rowsets = []

    try:
      req = {'List': query_list}
      response = self.client.call('SqlQuery.ExecuteBatch', req)
      for reply in response.reply['List']:
        fields = []
        conversions = []
        results = []
        rowcount = 0

        for field in reply['Fields']:
          fields.append((field['Name'], field['Type']))
          conversions.append(field_types.conversions.get(field['Type']))

        for row in reply['Rows']:
          results.append(tuple(_make_row(row, conversions)))

        rowcount = reply['RowsAffected']
        lastrowid = reply['InsertId']
        rowsets.append((results, rowcount, lastrowid, fields))
    except gorpc.GoRpcError as e:
      raise convert_exception(e, str(self), sql_list, bind_variables_list)
    except:
      logging.exception('gorpc low-level error')
      raise
    return rowsets
开发者ID:CERN-Stage-3,项目名称:vitess,代码行数:35,代码来源:tablet.py


示例7: _stream_execute

  def _stream_execute(self, sql, bind_variables):
    new_binds = field_types.convert_bind_vars(bind_variables)
    req = {
        'Sql': sql,
        'BindVariables': new_binds,
        'Keyspace': self.keyspace,
        'TabletType': self.tablet_type,
        'Shards': [self.shard],
    }
    self._add_session(req)

    self._stream_fields = []
    self._stream_conversions = []
    self._stream_result = None
    self._stream_result_index = 0
    try:
      self.client.stream_call('VTGate.StreamExecuteShard', req)
      first_response = self.client.stream_next()
      reply = first_response.reply

      for field in reply['Fields']:
        self._stream_fields.append((field['Name'], field['Type']))
        self._stream_conversions.append(field_types.conversions.get(field['Type']))
    except gorpc.GoRpcError as e:
      raise convert_exception(e, str(self), sql, bind_variables)
    except:
      logging.exception('gorpc low-level error')
      raise
    return None, 0, 0, self._stream_fields
开发者ID:jeffreywugz,项目名称:vitess,代码行数:29,代码来源:vtgate.py


示例8: _stream_execute2

  def _stream_execute2(self, sql, bind_variables):
    new_binds = field_types.convert_bind_vars(bind_variables)
    query = self._make_req()
    query['Sql'] = sql
    query['BindVariables'] = new_binds
    req = {'Query': query}

    self._stream_fields = []
    self._stream_conversions = []
    self._stream_result = None
    self._stream_result_index = 0
    try:
      self.client.stream_call('SqlQuery.StreamExecute2', req)
      first_response = self.client.stream_next()
      reply = first_response.reply
      if reply.get('Err'):
        self.__drain_conn_after_streaming_app_error()
        raise gorpc.AppError(reply['Err'].get('Message', 'Missing error message'))

      for field in reply['Fields']:
        self._stream_fields.append((field['Name'], field['Type']))
        self._stream_conversions.append(field_types.conversions.get(field['Type']))
    except gorpc.GoRpcError as e:
      self.logger_object.log_private_data(bind_variables)
      raise convert_exception(e, str(self), sql)
    except:
      logging.exception('gorpc low-level error')
      raise
    return None, 0, 0, self._stream_fields
开发者ID:forks-badal,项目名称:vitess,代码行数:29,代码来源:tablet.py


示例9: _create_v2_request_with_shards

def _create_v2_request_with_shards(
    sql, new_binds, keyspace_name, tablet_type, shards,
    not_in_transaction):
  """Make a request dict from arguments.

  Args:
    sql: Str sql with format tokens.
    new_binds: Dict of bind variables.
    keyspace_name: Str keyspace name.
    tablet_type: Str tablet_type.
    shards: String list of shards.
    not_in_transaction: Bool True if a transaction should not be started
      (generally used when sql is not a write).

  Returns:
    A (str: value) dict.
  """
  # keyspace_ids are Keyspace Ids packed to byte[]
  new_binds = field_types.convert_bind_vars(new_binds)
  req = {
      'Sql': sql,
      'BindVariables': new_binds,
      'Keyspace': keyspace_name,
      'TabletType': topodata_pb2.TabletType.Value(tablet_type.upper()),
      'Shards': shards,
      'NotInTransaction': not_in_transaction,
  }
  return req
开发者ID:benyu,项目名称:vitess,代码行数:28,代码来源:vtgatev2.py


示例10: _execute

    def _execute(self, sql, bind_variables):
        new_binds = field_types.convert_bind_vars(bind_variables)
        req = self._make_req()
        req["Sql"] = sql
        req["BindVariables"] = new_binds

        fields = []
        conversions = []
        results = []
        try:
            response = self.client.call("VTGate.ExecuteShard", req)
            reply = response.reply

            for field in reply["Fields"]:
                fields.append((field["Name"], field["Type"]))
                conversions.append(field_types.conversions.get(field["Type"]))

            for row in reply["Rows"]:
                results.append(tuple(_make_row(row, conversions)))

            rowcount = reply["RowsAffected"]
            lastrowid = reply["InsertId"]
        except gorpc.GoRpcError as e:
            raise convert_exception(e, str(self), sql, bind_variables)
        except:
            logging.exception("gorpc low-level error")
            raise
        return results, rowcount, lastrowid, fields
开发者ID:ZhuoRoger,项目名称:vitess,代码行数:28,代码来源:vtgate.py


示例11: _execute

  def _execute(self, sql, bind_variables):
    new_binds = field_types.convert_bind_vars(bind_variables)
    req = self._make_req()
    req['Sql'] = sql
    req['BindVariables'] = new_binds

    fields = []
    conversions = []
    results = []
    try:
      response = self.client.call('SqlQuery.Execute', req)
      reply = response.reply

      for field in reply['Fields']:
        fields.append((field['Name'], field['Type']))
        conversions.append(field_types.conversions.get(field['Type']))

      for row in reply['Rows']:
        results.append(tuple(_make_row(row, conversions)))

      rowcount = reply['RowsAffected']
      lastrowid = reply['InsertId']
    except gorpc.GoRpcError as e:
      self.logger_object.log_private_data(bind_variables)
      raise convert_exception(e, str(self), sql)
    except:
      logging.exception('gorpc low-level error')
      raise
    return results, rowcount, lastrowid, fields
开发者ID:bigrats,项目名称:vitess,代码行数:29,代码来源:tablet.py


示例12: _stream_execute

  def _stream_execute(self, sql, bind_variables):
    new_binds = field_types.convert_bind_vars(bind_variables)
    req = self._make_req()
    req['Sql'] = sql
    req['BindVariables'] = new_binds

    self._stream_fields = []
    self._stream_conversions = []
    self._stream_result = None
    self._stream_result_index = 0
    try:
      self.client.stream_call('SqlQuery.StreamExecute', req)
      first_response = self.client.stream_next()
      reply = first_response.reply

      for field in reply['Fields']:
        self._stream_fields.append((field['Name'], field['Type']))
        self._stream_conversions.append(field_types.conversions.get(field['Type']))
    except gorpc.GoRpcError as e:
      self.logger_object.log_private_data(bind_variables)
      raise convert_exception(e, str(self), sql)
    except:
      logging.exception('gorpc low-level error')
      raise
    return None, 0, 0, self._stream_fields
开发者ID:bigrats,项目名称:vitess,代码行数:25,代码来源:tablet.py


示例13: _stream_execute

  def _stream_execute(self, sql, bind_variables, keyspace, tablet_type, keyspace_ids=None, keyranges=None):
    new_binds = field_types.convert_bind_vars(bind_variables)
    exec_method = None
    req = None
    if keyspace_ids is not None:
      req = self._create_req_with_keyspace_ids(sql, new_binds, keyspace, tablet_type, keyspace_ids)
      exec_method = 'VTGate.StreamExecuteKeyspaceIds'
    elif keyrange is not None:
      req = self._create_req_with_keyranges(sql, new_binds, keyspace, tablet_type, keyranges)
      exec_method = 'VTGate.StreamExecuteKeyRanges'
    else:
      raise dbexceptions.ProgrammingError('_execute called without specifying keyspace_ids or keyranges')

    self._add_session(req)

    self._stream_fields = []
    self._stream_conversions = []
    self._stream_result = None
    self._stream_result_index = 0
    try:
      self.client.stream_call(exec_method, req)
      first_response = self.client.stream_next()
      reply = first_response.reply

      for field in reply['Fields']:
        self._stream_fields.append((field['Name'], field['Type']))
        self._stream_conversions.append(field_types.conversions.get(field['Type']))
    except gorpc.GoRpcError as e:
      raise convert_exception(e, str(self), sql, bind_variables)
    except:
      logging.exception('gorpc low-level error')
      raise
    return None, 0, 0, self._stream_fields
开发者ID:AndreMouche,项目名称:vitess,代码行数:33,代码来源:vtgatev2.py


示例14: _create_req

def _create_req(sql, new_binds, tablet_type):
  new_binds = field_types.convert_bind_vars(new_binds)
  req = {
        'Sql': sql,
        'BindVariables': new_binds,
        'TabletType': tablet_type,
        }
  return req
开发者ID:googlecode-copy,项目名称:vitess,代码行数:8,代码来源:vtgatev3.py


示例15: _create_req

def _create_req(sql, new_binds, tablet_type, not_in_transaction):
  new_binds = field_types.convert_bind_vars(new_binds)
  req = {
      'Sql': sql,
      'BindVariables': new_binds,
      'TabletType': tablet_type,
      'NotInTransaction': not_in_transaction,
  }
  return req
开发者ID:ruiaylin,项目名称:vitess,代码行数:9,代码来源:vtgatev3.py


示例16: _create_req_with_keyranges

def _create_req_with_keyranges(sql, new_binds, keyspace, tablet_type, keyranges):
  sql, new_binds = dbapi.prepare_query_bind_vars(sql, new_binds)
  new_binds = field_types.convert_bind_vars(new_binds)
  req = {
        'Sql': sql,
        'BindVariables': new_binds,
        'Keyspace': keyspace,
        'TabletType': tablet_type,
        'KeyRanges': [keyrange.KeyRange(kr) for kr in keyranges],
        }
  return req
开发者ID:poorman,项目名称:vitess,代码行数:11,代码来源:vtgatev2.py


示例17: _create_req_with_keyspace_ids

def _create_req_with_keyspace_ids(sql, new_binds, keyspace, tablet_type, keyspace_ids):
  sql, new_binds = dbapi.prepare_query_bind_vars(sql, new_binds)
  new_binds = field_types.convert_bind_vars(new_binds)
  req = {
        'Sql': sql,
        'BindVariables': new_binds,
        'Keyspace': keyspace,
        'TabletType': tablet_type,
        'KeyspaceIds': [str(kid) for kid in keyspace_ids],
        }
  return req
开发者ID:poorman,项目名称:vitess,代码行数:11,代码来源:vtgatev2.py


示例18: _execute_batch

  def _execute_batch(
      self, sql_list, bind_variables_list, keyspace_list, keyspace_ids_list,
      tablet_type, as_transaction, effective_caller_id=None):
    query_list = []
    for sql, bind_vars, keyspace, keyspace_ids in zip(
        sql_list, bind_variables_list, keyspace_list, keyspace_ids_list):
      sql, bind_vars = dbapi.prepare_query_bind_vars(sql, bind_vars)
      query = {}
      query['Sql'] = sql
      query['BindVariables'] = field_types.convert_bind_vars(bind_vars)
      query['Keyspace'] = keyspace
      query['KeyspaceIds'] = keyspace_ids
      query_list.append(query)

    rowsets = []

    try:
      req = {
          'Queries': query_list,
          'TabletType': tablet_type,
          'AsTransaction': as_transaction,
      }
      self._add_caller_id(req, effective_caller_id)
      self._add_session(req)
      response = self._get_client().call('VTGate.ExecuteBatchKeyspaceIds', req)
      self._update_session(response)
      if response.reply.get('Error'):
        raise gorpc.AppError(
            response.reply['Error'], 'VTGate.ExecuteBatchKeyspaceIds')
      for reply in response.reply['List']:
        fields = []
        conversions = []
        results = []
        rowcount = 0

        for field in reply['Fields']:
          fields.append((field['Name'], field['Type']))
          conversions.append(field_types.conversions.get(field['Type']))

        for row in reply['Rows']:
          results.append(tuple(_make_row(row, conversions)))

        rowcount = reply['RowsAffected']
        lastrowid = reply['InsertId']
        rowsets.append((results, rowcount, lastrowid, fields))
    except gorpc.GoRpcError as e:
      self.logger_object.log_private_data(bind_variables_list)
      raise self._convert_exception(
          e, sql_list, keyspace_ids_list,
          keyspace='', tablet_type=tablet_type)
    except Exception:
      logging.exception('gorpc low-level error')
      raise
    return rowsets
开发者ID:xgwubin,项目名称:vitess,代码行数:54,代码来源:vtgatev2.py


示例19: _create_req_with_keyranges

def _create_req_with_keyranges(sql, new_binds, keyspace, tablet_type, keyranges):
  # keyranges are keyspace.KeyRange objects with start/end packed to byte[]
  sql, new_binds = dbapi.prepare_query_bind_vars(sql, new_binds)
  new_binds = field_types.convert_bind_vars(new_binds)
  req = {
        'Sql': sql,
        'BindVariables': new_binds,
        'Keyspace': keyspace,
        'TabletType': tablet_type,
        'KeyRanges': keyranges,
        }
  return req
开发者ID:gwmullin,项目名称:vitess,代码行数:12,代码来源:vtgatev2.py


示例20: _create_req_with_keyspace_ids

def _create_req_with_keyspace_ids(sql, new_binds, keyspace, tablet_type, keyspace_ids):
  # keyspace_ids are Keyspace Ids packed to byte[]
  sql, new_binds = dbapi.prepare_query_bind_vars(sql, new_binds)
  new_binds = field_types.convert_bind_vars(new_binds)
  req = {
        'Sql': sql,
        'BindVariables': new_binds,
        'Keyspace': keyspace,
        'TabletType': tablet_type,
        'KeyspaceIds': keyspace_ids,
        }
  return req
开发者ID:gwmullin,项目名称:vitess,代码行数:12,代码来源:vtgatev2.py



注:本文中的vtdb.field_types.convert_bind_vars函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python topology.read_topology函数代码示例发布时间:2022-05-26
下一篇:
Python dbapi.prepare_query_bind_vars函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap