Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def filter(self,
- table_name: str,
- row: str = None,
- value: str = None,
- read_mode: str = 'outdated',
- time_format: str = 'native',
- profile: bool = False,
- durability: str = 'soft',
- group_format: str = 'native',
- noreply: bool = False,
- array_limit: int = 100000,
- binary_format: str = 'native',
- min_batch_rows: int = 8,
- max_batch_rows: int = 10,
- max_batch_bytes: int = 1,
- max_batch_seconds: float = 0.5,
- fbsf: int = 8,
- ) -> r.net.DefaultCursor:
- try:
- if row and value:
- """Return a list of specific data.
- row must be the same name of the table's row desired to filter.
- value is the compare value desired to filter.
- Example:
- row='name' and value='John'.
- """
- return (
- r.table(table_name).filter(r.row[row] == value)
- .run(self.__conn,
- read_mode=read_mode,
- time_format=time_format,
- profile=profile,
- durability=durability,
- group_format=group_format,
- noreply=noreply,
- array_limit=array_limit,
- binary_format=binary_format,
- min_batch_rows=min_batch_rows,
- max_batch_rows=max_batch_rows,
- max_batch_bytes=max_batch_bytes,
- max_batch_seconds=max_batch_bytes,
- first_batch_scaledown_factor=fbsf
- )
- )
- else:
- """Return a single JSON result or a cursor."""
- return (
- r.table(table_name)
- .run(self.__conn,
- read_mode=read_mode,
- time_format=time_format,
- profile=profile,
- durability=durability,
- group_format=group_format,
- noreply=noreply,
- array_limit=array_limit,
- binary_format=binary_format,
- min_batch_rows=min_batch_rows,
- max_batch_rows=max_batch_rows,
- max_batch_bytes=max_batch_bytes,
- max_batch_seconds=max_batch_bytes,
- first_batch_scaledown_factor=fbsf
- )
- )
- except errors.ReqlError as error:
- print('Error: ', error)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement