Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
A simple Database Management System for users who want self-contained DBMS that uses YAML File format to store values.
A lightweight, serverless database management system that stores data in a Binary YAML format, supports basic CRUD operations, query processing with mathematical functions, and optional encryption for data security. This is tailored for projects that needed DBMS without management of server process. This serves as database for eazy-home-server.
To install the package for python, use pip package manager.
pip install quick_yaml
This section will be expanded later in https://gitlab.com/eazy-home-admin/QuickYAML/-/wikis/home
from quick_yaml.manager import QYAMLDB
db = QYAMLDB('f.ezdb','f.key',encrypted=True) # Encrpytion by default is optional
db.create_table('sample', unique_columns=['name'] ) # Indexes to be bought in future.
data = {'name': 'Test Item', 'value': 42}
db.insert_new_data('sample', data) # Insert a data
QuickYAML aims to provide a rich set of query features that facilitate deep and flexible interaction with the data. These features are designed to cater to both simple and complex data manipulation needs, ensuring users can easily retrieve, analyze, and modify data as required. Below, we expand on the proposed query features, highlighting their functionality and potential use cases within QuickYAML.
QuickYAML plans to leverage Pandas, a powerful data analysis and manipulation library, to provide advanced querying capabilities. This integration will allow for sophisticated data operations that are both efficient and intuitive.
Range Queries ($range
): Allows for retrieving records where a specified field falls within a given range. This is crucial for scenarios where boundaries define the data of interest, such as dates or numerical thresholds.
Comparison Queries:
$gt
): Retrieves records where a field's value is greater than a specified value.$lt
): Similar to $gt
but for values less than the specified value.$ge
): Extends $gt
to include equality.$le
): Extends $lt
to include equality.$eq
): Retrieves records with a field's value exactly matching the specified value.Membership Query ($in
): Fetches records where a field's value matches any in a specified set of values.
This is particularly useful for filtering data based on a list of identifiers, categories, or any discrete set of values.
Pattern Matching ($like
): Offers regex-based querying to find records where a text field matches a given pattern.
This feature is invaluable for text search, allowing for flexible matching based on partial text, patterns, or conditions.
String Search ($contains
): Offers a regex-based querying to search for substring present in the key.
Group By ($group_by
): This operation groups records by one or more fields, facilitating aggregate calculations
or summaries on these groups. It's essential for analytical queries where understanding data in segments or categories is required.
Sort ($sort
): Orders the records based on one or more fields, in ascending or descending order. Sorting is
fundamental for organizing query results, especially in reporting or when order matters in data presentation.
$select
): Allows specifying a subset of fields to be returned in the query results.
This feature helps focus on relevant data, reducing the overhead of processing and transferring unnecessary information.QuickYAML supports a variety of aggregate functions that can be used to perform calculations on a dataset. These functions are crucial for data analysis and can provide significant insights into the data. Below is a description of each aggregate function supported by QuickYAML.
$sum
: Calculates the total sum of numeric values in a specified field.$avg
(Average): Computes the average of numeric values in a specified field.$count
: Counts the number of items in the dataset or a specific group.$max
: Finds the maximum value among numeric values in a specified field.$min
: Finds the minimum value among numeric values in a specified field.$median
: Determines the median value among numeric values in a specified field.$mode
: Finds the mode (the most frequently occurring value) in a specified field.$stddev
(Standard Deviation): Calculates the standard deviation of numeric values in a specified field, indicating the dispersion of data points.$variance
: Calculates the variance of numeric values in a specified field, measuring the degree of variation.Aggregate functions can be used as part of the $operations
component of a query. These operations can be applied
directly to the dataset or to data that has been grouped using the $groupby
operation.
Here is an example query that uses aggregate functions:
{
"$filter": {
"price": {"$gt": 100}
},
" $groupby": "category",
"$operations": [
{"$action": "$sum", "$on": "price"},
{"$action": "$avg", "$on": "price"}
]
}
In this example, the dataset is first filtered to include only items with a price greater than 100. Then, the data is grouped by the "category" field. Finally, two aggregate operations are performed on each group: summing the prices and calculating the average price.
$select
When using aggregate functions in a query, it is not recommended to use the $select
operation in conjunction with $operations
. This is because aggregate functions typically reduce the dataset to summary values, which may not align with the field projections specified in $select
.
Access Sub-keys:
key1.subkey1.
Where conditions:
command = {
"$filter": {
"key1": {"$gt": 10} # by default all the conditions of data should match
},
"$groupby": "key2",
"$sort": ["time", "type"],
"$select": ["key3.subkey"],
"$operations": [
{"$operation": "sum", "$on": "key4"},
{"$operation": "average", "$on": "key5"}
]
}
Example for queries with $and , $or
command ={
"$filter": {
"$and": [
{"key1": {"$gt": 10}},
{
"$or": [
{"key2": {"$lt": 20}},
{"key3.subkey": {"$eq": "someValue"}}
]
}
]
},
"$groupby": "key2",
"$sort": ["time", "type"],
"$select": ["key3.subkey"],
"$operations": [
{"$action": "$sum", "$on": "key4"},
{"$action": "$avg", "$on": "key5"}
]
}
$filter
$groupby
$sort
$select
$operations
(Aggregations)Transactions in our database management system provide a mechanism for batch executing a series of commands, ensuring that all commands within a transaction are completed without errors. This functionality emulates the transactional capabilities found in traditional DBMS, enhancing reliability and consistency during batch operations. To further enhance error handling during transactions, we support three distinct error control strategies:
The format for defining a transaction is structured to clearly specify each operation within the transaction, the table involved, and the data being manipulated or criteria being applied. Here is an example of a transaction that includes various operations such as insert, insert_many, delete, delete_many, update, and update_many:
{
"$transaction_id": 100,
"$commands": [
{ "type": "$insert", "$table_name": "my_table", "$data": {"name": "Alice", "age": 30} },
{ "type": "$insert_many", "$table_name": "my_table", "$data": [{"name": "Bob", "age": 25}, {"name": "Charlie", "age": 35}] },
{ "type": "$delete", "$table_name": "my_table", "$obj_id": "2" },
{ "type": "$delete_many", "$table_name": "my_table", "$condition": {"age": {"$gt": 32}} },
{ "type": "$update", "$table_name": "my_table", "$obj_id": "3", "$data": {"age": 28} },
{ "type": "$update_many", "$table_name": "my_table", "$condition": {"name": "Alice"}, "$data": {"age": 31}, "$flags": {} }
{ "type": "$create_table", "$table_name": "my_table"}
],
"$on_error": "rollback" | "continue" | "break",
"$on_invalid_command": 'break' | 'rollback' | 'continue';
}
Each transaction is uniquely identified by a $transaction_id
and specifies a list of $operations
to be performed. The $on_error
field determines the error control strategy to be applied in case of an operation failure within the transaction. This structured approach to defining and executing transactions ensures that batch operations are performed reliably and according to the specified error handling strategy, thereby enhancing data integrity and consistency.
FAQs
A simple Database Management System for users who want self-contained DBMS that uses YAML File format to store values.
We found that quick-yaml demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.