Exemplo n.º 1
0
def create_slice(
    datasource_id: Optional[int] = None,
    datasource: Optional[SqlaTable] = None,
    name: Optional[str] = None,
    owners: Optional[List[User]] = None,
) -> Slice:
    name = name if name is not None else random_str()
    owners = owners if owners is not None else []
    datasource_type = "table"
    if datasource:
        return Slice(
            slice_name=name,
            table=datasource,
            owners=owners,
            datasource_type=datasource_type,
        )

    datasource_id = (datasource_id if datasource_id is not None else
                     create_datasource_table_to_db(name=name + "_table").id)

    return Slice(
        slice_name=name,
        datasource_id=datasource_id,
        owners=owners,
        datasource_type=datasource_type,
    )
Exemplo n.º 2
0
def create_datasource_table(
    name: Optional[str] = None,
    db_id: Optional[int] = None,
    owners: Optional[List[User]] = None,
) -> SqlaTable:
    name = name or random_str()
    owners = owners or []
    db_id = db_id or create_database_to_db(name=name + "_db").id
    return SqlaTable(table_name=name, database_id=db_id, owners=owners)
Exemplo n.º 3
0
def create_datasource_table(
    name: Optional[str] = None,
    db_id: Optional[int] = None,
    database: Optional[Database] = None,
    owners: Optional[List[User]] = None,
) -> SqlaTable:
    name = name if name is not None else random_str()
    owners = owners if owners is not None else []
    if database:
        return SqlaTable(table_name=name, database=database, owners=owners)
    db_id = db_id if db_id is not None else create_database_to_db(name=name + "_db").id
    return SqlaTable(table_name=name, database_id=db_id, owners=owners)
Exemplo n.º 4
0
def create_slice(
    datasource_id: Optional[int], name: Optional[str], owners: Optional[List[User]]
) -> Slice:
    name = name or random_str()
    owners = owners or []
    datasource_id = (
        datasource_id or create_datasource_table_to_db(name=name + "_table").id
    )
    return Slice(
        slice_name=name,
        datasource_id=datasource_id,
        owners=owners,
        datasource_type="table",
    )
Exemplo n.º 5
0
def create_database(name: Optional[str] = None) -> Database:
    name = name if name is not None else random_str()
    return Database(database_name=name, sqlalchemy_uri="sqlite:///:memory:")