MindLake.DataLake
1. query() Method
Execute a SQL query or command.
mindlake.datalake.query(executeSql: str) -> ResultType
# mindlake is an instance of MindLake
Parameters
executeSql -
str
: the SQL statement used to query Mind Lake, such asSELECT, INSERT, UPDATE, and DELETE
.
Returns
An object of . For more information.
data
-dict
: The result of query execution.{ 'columnList': [], 'data': [][] }
columnList -
list<str>
: the column names in the specific order in which they appear.data -
list<list<str>>
: The query data result is presented as a 2D array, with rows and columns.
Example
result = mind.datalake.query("SELECT token FROM test_table_enc")
assert result, result.message
print(result.data['columnList'][0])
for row in result.data['data']:
result = mind.cryptor.decrypt(row[0])
assert result, result.message
print(result.data)
2. createTable() Method
Create a table in the user's own account in Mind Lake.
mindlake.datalake.createTable(tableName: str, columns: list, primaryKey: list = None) -> ResultType
# mindlake is an instance of MindLake
Parameters
tableName
-str
: the name of the table to be created.columns
-list<
Column
>
: defines the columns in the table. Each column should be defined as aMindLake.DataLake.Column
object.primaryKey
(Optional) -list<str>
: defines the table's primary key by specifying one or more columns. Each column in the primary key should be identified by its column name. If theprimaryKey
parameter is omitted, no primary key will be defined for the table.
Returns
An object of . For more information.
Example
result = mindlake.datalake.createTable('test_table_enc',
[
mindlake.datalake.Column('id', mindlake.DataType.int4, False),
mindlake.datalake.Column('token', mindlake.DataType.text, True)
])
assert result, result.message
3. MindLake.DataLake.Column
Column
type is used to represent a single column in a table. Each Column
instance encapsulates properties about the column, including its name, data type, and encryption status. By creating a Column
object, you can define the properties of a table column and use it to construct a table schema.
class Column(dict):
def __init__(self, columnName: str, dataType: DataType, encrypt: bool):
self.columnName = columnName
self.type = dataType
self.encrypt = encrypt
def toDict(self):
return {
'columnName': self.columnName,
'type': self.type.value,
'encrypt': self.encrypt
}
Fields
columnName
-str
: The name of the column.dataType
-MindLake.DataType
: The data type of the column, which should be define asMindLake.DataType
encrypt
-bool
: A flag that indicates whether the column should be encrypted or not.
4. listTablesByCocoon() Method
Retrieve a list of names for the tables that belong to the user invoking the method, or in the specified cocoon.
mindlake.datalake.listTablesByCocoon(cocoonName: str) -> ResultType
# mindlake is an instance of MindLake
Parameters
cocoonName
-str
: specifies the name of the cocoon for which a list of tables should be returned.
Returns
An object of . For more information.
data
-list<str>
: a list of names for the tables that belong to the user invoking the method, or in the specified cocoon.
Example
result = mindlake.datalake.listTablesByCocoon(cocoonName)
assert result, result.message
tableList = result.data
5. createCocoon() Method
Create a Cocoon in Mind Lake. Tables can be categorized into cocoons for classification purposes.
mindlake.datalake.createCocoon(cocoonName: str) -> ResultType
# mindlake is an instance of MindLake
Parameters
cocoonName
-str
: the name of the cocoon to be created.
Returns
An object of . For more information.
Example
result = mindlake.datalake.createCocoon(cocoonName)
assert result, result.message
6. listCocoon() Method
Retrieve a list of names for the cocoons that belong to the user invoking the method.
mindlake.datalake.listCocoon() -> ResultType
# mindlake is an instance of MindLake
Returns
An object of . For more information.
data
-list<str>
: a list of names for the cocoons that belong to the user invoking the method.
Example
result = mindlake.datalake.listCocoon()
assert result, result.message
cocoonList = result.data
7. linkTableToCocoon() Method
Assign the specified cocoon tag to the table.
mindlake.datalake.linkTableToCocoon(tableName: str, cocoonName: str) -> ResultType
# mindlake is an instance of MindLake
Parameters
tableName
-str
: the name of the table to be tagged with.cocoonName
-str
: specifies the name of the cocoon for which the table should be tagged with.
Returns
An object of . For more information.
Example
result = mindlake.datalake.linkTableToCocoon(tableName, cocoonName)
assert result, result.message
8. dropCocoon() Method
Delete a Cocoon in Mind Lake.
mindlake.datalake.dropCocoon(cocoonName: str) -> ResultType
# mindlake is an instance of MindLake
Parameters
cocoonName
-str
: the name of the cocoon to be dropped.
Returns
An object of . For more information.
Example
result = mindlake.datalake.dropCocoon(cocoonName)
assert result, result.message
9. dropTable() Method
Drop a table in the user's own account in Mind Lake.
mindlake.datalake.dropTable(tableName: str, columns: list, primaryKey: list = None) -> ResultType
Parameters
tableName
-str
: the name of the table to be dropped.
Returns
An object of . For more information.
Example
result = mindlake.datalake.dropTable(cocoonName)
assert result, result.message
Last updated