Esempio n. 1
0
    def _start(self, term, **global_opt_args):
        token = self.next_token
        self.next_token += 1

        # Construct query
        query = p.Query()
        query.type = p.Query.START
        query.token = token

        # Set global opt args

        # The 'db' option will default to this connection's default
        # if not otherwise specified.
        if 'db' in global_opt_args:
            global_opt_args['db'] = DB(global_opt_args['db'])
        else:
            if self.db:
                global_opt_args['db'] = DB(self.db)

        for k, v in global_opt_args.items():
            pair = query.global_optargs.add()
            pair.key = k
            expr(v).build(pair.val)

        # Compile query to protobuf
        term.build(query.query)
        return self._send_query(query, term, global_opt_args)
Esempio n. 2
0
    def _start(self, term, **global_optargs):
        # Set global opt args
        # The 'db' option will default to this connection's default
        # if not otherwise specified.
        if 'db' in global_optargs:
            global_optargs['db'] = DB(global_optargs['db'])
        else:
            if self.db:
                global_optargs['db'] = DB(self.db)

        # Construct query
        query = Query(pQuery.START, self.next_token, term, global_optargs)
        self.next_token += 1
        return self._send_query(query, global_optargs)
Esempio n. 3
0
 def _start(self, term, **global_optargs):
     self.check_open()
     if "db" in global_optargs or self.db is not None:
         global_optargs["db"] = DB(global_optargs.get("db", self.db))
     q = Query(pQuery.START, self._new_token(), term, global_optargs)
     return self._instance.run_query(q,
                                     global_optargs.get("noreply", False))
Esempio n. 4
0
 async def _start(self, term, **options):
     self.check_open()
     if 'db' in options or self.db is not None:
         options['db'] = DB(options.get('db', self.db))
     q = Query(QueryType.START, self._new_token(), term, options)
     return await self._run_query(q,
                                  noreply=options.get('noreply', False),
                                  raise_for_errors=options.get(
                                      'raise_for_errors', True))
Esempio n. 5
0
 def _create_index(db_query: DB, table_name, index_name, index_func):
     return db_query.table(table_name).index_create(
         index_name, index_func).do(
             lambda _: db_query.table(table_name).index_wait(index_name))
Esempio n. 6
0
 def _ensure_table_query(db_query: DB, table_name):
     return db_query.table_list() \
         .contains(table_name) \
         .branch(
         {"tables_created": 0},
         db_query.table_create(table_name))