Divooka.DataGrid.InMemoryDB
Divooka.DataGrid.InMemoryDB.EasyQuery
A SQL-like interface combining DataGrid and InMemoryDB usages, providing quick one-shot use high-level operations that's similar to SQL and is based on SQL.
Remarks
Used to be called "MiniSQL".
TODO: Based on current language setting, provide language-specific keyword handling.
Divooka.DataGrid.InMemoryDB.EasyQuery.Extract()
Initialize a SQL database with data grid, perform a SELECT query to create a view, then return the resulting view.
Parameters
| Name | Description | Default |
|---|---|---|
dataGrid |
Source data grid | |
expresion |
A simple SQL SELECT clause |
Divooka.DataGrid.InMemoryDB.EasyQuery.Filter()
Initialize a SQL database with data grid, perform a SELECT query to create a view, then return the resulting view.
Parameters
| Name | Description | Default |
|---|---|---|
condition |
A simple SQL SELECT where clause, with some customization that supports our custom own comma based syntax (default as "AND") |
Divooka.DataGrid.InMemoryDB.EasyQuery.GroupBy()
Initialize a SQLite in-memory database with input data grid, perform a SELECT query to create a view, then return the resulting view.
Aggregate functions: avg(X), count(*), count(X), group_concat(X), group_concat(X,Y), max(X), min(X), string_agg(X,Y), sum(X), total(X), first(X), last(X).
Filter is applied on the original data grid, while the rules are applied on the groups and you can use aggregate functions like count() or distinct().
Parameters
| Name | Description | Default |
|---|---|---|
dataGrid |
Input data. | |
optionalFilter |
A filter before grouping by | |
by |
The groups to extract; Equivalent to SQL GROUP BY clause. | |
expression |
The columns to select; Equivalent to SQL SELECT clause. Leave empty to select the groups themselves. | |
aggregateCondition |
Optional rules on the final result, equivalent to SQL HAVING clause. |
Divooka.DataGrid.InMemoryDB.EasyQuery.GroupBy()
Initialize a SQL database with data grid, perform a SELECT query to create a view, then return the resulting view.
Aggregate functions: avg(X), count(*), count(X), group_concat(X), group_concat(X,Y), max(X), min(X), string_agg(X,Y), sum(X), total(X), first(X), last(X).
Parameters
| Name | Description | Default |
|---|---|---|
dataGrid |
Input data. | |
expression |
What to do on the groups, equivalanet to SQL SELECT clause. Leave empty to select the groups themselves. | |
by |
The groups to create, equivalent to SQL GROUP BY clause. |
Divooka.DataGrid.InMemoryDB.EasyQuery.GroupCut()
Slices a data grid by a specified dimension (column), and perform aggregation based on selected keys.
Remarks
TODO: Provide lambda based versions.
Parameters
| Name | Description | Default |
|---|---|---|
dataGrid |
Input data | |
attributes |
The "keys" on the rows | |
dimension |
The single numerical column to be sliced and aggregated with the aggregation function. | |
slices |
Either total number of slices, or comma or dash delimited value boundaries. | |
function |
The method of aggregation for the sliced dimension. Currently only Divooka.DataAnalytics.DivookaDataGridTransformation.AggregateFunction.Count is implemented. |
Result
Output data table with the selected dimension column sliced into multiple columns.
Divooka.DataGrid.InMemoryDB.EasyQuery.PerformQuery()
Initialize a SQL database with data grid, perform a SELECT query to create a view, then return the resulting view.
Remarks
Notice at the moment for complex query that returns field names containing special characters it may not display well - in that case just make sure to include an "As" term, e.g. `select last(price)/first(price) - 1 as totalReturn from table1`
Parameters
| Name | Description | Default |
|---|---|---|
query |
A simple SQL SELECT query from the named data grid. For table name, just use `Table1` or provide an explicit name, otherwise it will fallback to DataGrid's internal table name or use a fallback `TempTable`. Notice table name must be quoted otherwise it will be a syntax error. | |
dataGrid |
Input data | |
tableNameOverride |
A name of the table to be used in query; Notice one should avoid "Table" since it's a keyword |
Returns
Result data
Divooka.DataGrid.InMemoryDB.EasyQuery.SQL()
Perform SQL query directly on incoming tables.
Super useful for practical and demonstrational use.
Parameters
| Name | Description | Default |
|---|---|---|
tables |
Divooka data grids as table. | |
query |
Query on the table. Table names are formatted as `Table1`, `Table2`, etc. |
Returns
Query result
Divooka.DataGrid.InMemoryDB.EasyQuery.SQL()
Perform SQL query directly on incoming tables.
Super useful for practical and demonstrational use.
Divooka.DataGrid.InMemoryDB.EasyQuery.SQL()
Perform SQL query directly on incoming tables.
Super useful for practical and demonstrational use.
Parameters
| Name | Description | Default |
|---|---|---|
tableNames |
Names of tables on each line. |
Divooka.DataGrid.InMemoryDB.EasyQuery.CleanSqlClause()
Removes alias definitions in a SQL clause. For example, given "Gender, strftime('%m', \"Date of Birth\") as BirthYear" it returns "Gender, strftime('%m', \"Date of Birth\")"
Parameters
| Name | Description | Default |
|---|---|---|
clause |
The SQL clause to clean. |
Returns
The SQL clause without alias definitions.
Divooka.DataGrid.InMemoryDB.InMemoryDBDataGridIntegration.ImportAsTable()
Import new table; Table mustn't already exist.
Divooka.DataGrid.InMemoryDB.InMemorySQLite
TODO: Change to Microsoft SQLite
Remarks
This library is heavily stated and not suited for PV1 Neo use yet (unless we create an immutable version).
We are calling it "InMemorySQLite instead of InMemoryDB because unfortunately that name is already taken by the namespace".
Divooka.DataGrid.InMemoryDB.InMemorySQLite.InMemorySQLiteDatabaseConnectionSourceNameToken
Remarks
Internal/Cross-module use only, might want to hide from Parcel front-ends.
TODO: (DiOS) Support hiding members.
Divooka.DataGrid.InMemoryDB.InMemorySQLite.#ctor()
Parameters
| Name | Description | Default |
|---|---|---|
dataSource |
Can be either file path to SQLite DB, a network connection (socket), or :memory: | |
withExtendedFunctionSet |
Whether or not to use "Divooka SQL" dialect |
Divooka.DataGrid.InMemoryDB.InMemorySQLite.Connect()
Provides a semantic endpoint for connecting to file/path/protocol service (socket).
Divooka.DataGrid.InMemoryDB.InMemorySQLite.Execute()
Execute arbitrary query. This functions combines query/non-query type execution in a single function.
Divooka.DataGrid.InMemoryDB.InMemorySQLite.ImportAsTable()
Import string values as table
Divooka.DataGrid.InMemoryDB.InMemorySQLite.CreateTable()
Create empty table.
Divooka.DataGrid.InMemoryDB.InMemorySQLite.AppendToTable()
Append to existing table.
Divooka.DataGrid.InMemoryDB.InMemorySQLite.MigrateInto()
Migrate table from current InMemoryDB to another; If target table already exists, simply append to it.
Divooka.DataGrid.InMemoryDB.InMemorySQLite.Export()
Export SQLite database file
Divooka.DataGrid.InMemoryDB.InMemorySQLite.Views
Get names of all views
Divooka.DataGrid.InMemoryDB.InMemorySQLite.Tables
Get names of all tables
Divooka.DataGrid.InMemoryDB.InMemorySQLite.TablesAndViews
Get names of all tables and views
Divooka.DataGrid.InMemoryDB.InMemorySQLite.Item()
Get table
Divooka.DataGrid.InMemoryDB.InMemorySQLite.ContainsTableOrView()
Check precense of either table or view