@bluepineapple-nebbia-tech/query-tool
v1.0.1
Published
Introducing "query_tool" - a powerful and user-friendly npm package designed to simplify your data analysis. With its intuitive interface, you can easily select the desired databases, columns, and tables, and apply filters, dimensions, and measures to ana
Downloads
7
Readme
Query Tool
Introducing "query_tool" - a powerful and user-friendly npm package designed to simplify your data analysis. With its intuitive interface, you can easily select the desired databases, columns, and tables, and apply filters, dimensions, and measures to analyze your data. Whether you're a beginner or an experienced analyst, "query_tool" is the perfect tool for your data analysis needs.
Installation
npm i @bluepineapple-nebbia-tech/data-grid
Usage
import QueryTool from "@bluepineapple-nebbia-tech/query-tool";
...
databases = ['COMPANY_DB', 'SALES_DB']
tables = [
{
'database': 'COMPANY_DB',
'tables': ['EMPLOYEES', 'DEPARTMENTS']
},
{
'database': 'SALES_DB',
'tables': ['CUSTOMERS', 'ORDERS']
}
]
columns = [
{
'fqtn': 'COMPANY_DB.EMPLOYEES',
'columns': ['ID', 'NAME', 'EMAIL', 'POSITION']
},
{
'fqtn': 'COMPANY_DB.DEPARTMENTS',
'columns': ['ID', 'NAME', 'LOCATION', 'MANAGER']
},
{
'fqtn': 'SALES_DB.CUSTOMERS',
'columns': ['ID', 'NAME', 'EMAIL', 'PHONE']
},
{
'fqtn': 'SALES_DB.ORDERS',
'columns': ['ID', 'PRODUCT', 'QUANTITY', 'DATE']
}
]
<QueryTool
title="Query Tool"
database_list={databases}
table_list={tables}
column_list={columns}
query="Select * from QueryTool where query_tool = 'query_tool ' and database = 123"
error=""
show_execute={true},
onChange={(data) => {}}
/>
API
Properties
| Property | Description | | ------------- | :-------------------------------------------: | | title | The title of the query tool. | | query | The query to be showned in the query section. | | database_list | An array of available databases. | | table_list | An array of available tables. | | column_list | An array of available columns. | | show_execute | Show execute button below the query section. | | error | Error to show on the ui |
Methods
| Method | Parameters | Usage | | -------- | :--------- | :--------------------------------------------------------: | | onChange | data | Data format will be change as per action | | onResize | | A callback function called when the query tool is resized. |
onChange
1. Database Change
data: { action: 'database_change', database: '{selected_database}':}
Usage:
<QueryTool
...
onChange={(data) => {
console.log(data);
//output - { action: 'database_change', database: '{selected_database}' }
}}
/>
2. Table Change
data: { action: 'database_change', database: '{selected_database}', table: '{selected_table}' }
Usage:
<QueryTool
...
onChange={(data) => {
console.log(data);
//output - { action: 'database_change', database: '{selected_database}', table: '{selected_table}' }
}}
/>
3. Preview Query
data: { action: 'preview_query', entity_data: [], filter_data: [], dimension_data: [] }
Usage:
<QueryTool
...
onChange={(data) => {
console.log(data);
//output - { action: 'preview_query', entity_data: [], filter_data: [], dimension_data: [], options: { limit: 100 } }
}}
/>
Data format:
1. entity_data
[
{
"database": "COMPANY_DB",
"table": "EMPLOYEES",
"columns": [
"ID",
"EMAIL",
"NAME",
"SKILLS"
],
"relationship": [],
"id": "f3f409ad-ea87-4016-b56d-890292c14caa"
},
{
"database": "COMPANY_DB",
"table": "DEPARTMENTS",
"columns": [
"ID",
"EMAIL",
"NAME",
"SKILLS"
],
"relationship": [
{
"id": "7fdf54d1-ca78-4186-9076-d981159a1d85",
"leftColumnFqcn": "ID",
"joinType": "LEFT JOIN",
"rightColumnDatabase": "COMPANY_DB",
"rightColumnTable": "EMPLOYEES",
"rightColumnColumn": "ID"
}
],
"id": "2490bd73-0d37-4361-ba50-2d9efb2b671a"
}
]
2. filter_data
[
{
"fqcn": "BLUEPINEAPPLE.PES.DEVELOPERS.SKILLS",
"operator": "LIKE",
"value": "ReactJS",
"id": "fe27d318-3535-4605-a8ae-c723db39703d",
"connector": "",
"filtersList": [
{
"fqcn": "BLUEPINEAPPLE.PES.DEVELOPERS.NAME",
"operator": "NO"
}
]
}
]
3. dimension_data
[
{
"dimension": "GROUP BY",
"database": "BLUEPINEAPPLE",
"table": "PES.DEVELOPERS",
"column": "ID",
"measures": [
{
"id": "60273711-ac85-474a-be21-bf1a292ee796",
"fqcn": "BLUEPINEAPPLE.PES.DEVELOPERS.EMAIL",
"measure": "COUNT"
}
],
"id": "852b1a34-87aa-4674-b618-cb66a3577230"
}
]
4. Options
{ limit: 100 }
// SQL query limit on number of records
4. Copy to Clipboard
data: { action: 'copy_to_clipboard', query: query }
Usage:
<QueryTool
...
onChange={(data) => {
console.log(data);
//output - { action: 'copy_to_clipboard', query: query }
}}
/>