Exemplo n.º 1
0
 def __init__(self, query_params: Dict[str, Any]):
     self.create_table_as_select = None
     self.database = None
     self._init_from_query_params(query_params)
     self.user_id = self._get_user_id()
     self.client_id_or_short_id = cast(
         str, self.client_id or utils.shortid()[:10])
Exemplo n.º 2
0
def example_query(
        get_or_create_user: Callable[..., ContextManager[ab_models.User]]):
    with get_or_create_user("sqllab-test-user") as user:
        query = Query(client_id=shortid()[:10],
                      database=get_example_database(),
                      user=user)
        db.session.add(query)
        db.session.commit()
        yield query
        db.session.delete(query)
        db.session.commit()