ElephantSqlDBClient 1.0.151
dotnet add package ElephantSqlDBClient --version 1.0.151
NuGet\Install-Package ElephantSqlDBClient -Version 1.0.151
<PackageReference Include="ElephantSqlDBClient" Version="1.0.151" />
<PackageVersion Include="ElephantSqlDBClient" Version="1.0.151" />
<PackageReference Include="ElephantSqlDBClient" />
paket add ElephantSqlDBClient --version 1.0.151
#r "nuget: ElephantSqlDBClient, 1.0.151"
#:package ElephantSqlDBClient@1.0.151
#addin nuget:?package=ElephantSqlDBClient&version=1.0.151
#tool nuget:?package=ElephantSqlDBClient&version=1.0.151
@icon-database Highspeed Quantum Database Documentation
<nav class="mm-tree"> <details open> <summary>Getting Started</summary> <ul> <li><a href="#step-1-elephantsqldb-welcome-email-with-database-credits">Step 1. ElephantSqlDB® Welcome Email with Database Credits </a></li> <li><a href="#step-2-elephantsqldb-credentials-email">Step 2. ElephantSqlDB® Credentials Email</a></li> <li><a href="#step-3-elephantsqldb-sql-management-portal-registration">step 3. ElephantSqlDB® SQL Management Portal Registration</a></li> <li><a href="#step-4-logging-into-elephantsqldb">Step 4. Logging Into ElephantSqlDB®</a></li> </ul> </details>
<details>
<summary>ElephantSqlDB® SQL Management Portal</summary>
<ul>
<li><a href="#creating-a-new-database">Step 1. Creating a new Database</a></li>
<li><a href="#building-your-database">Step 2. Building your Database</a></li>
<li><a href="#importing-an-existing-database">Step 3. Importing an Existing Database</a></li>
<li><a href="#importing-database-schema">Step 4. Importing Database Schema</a></li>
<li><a href="#confirming-imported-schema">Step 5. Confirming Imported Schema</a></li>
<li><a href="#importing-data">Step 6. Importing Data</a></li>
<li><a href="#updating-your-workspace">Step 7. Updating your Workspace</a></li>
<li><a href="#setting-up-users">Step 8. Setting up Users</a></li>
<li><a href="#user-management">Step 9. User Management</a></li>
<li><a href="#restoring-from-daily-backups">Step 10. Restoring from Daily Backups</a></li>
</ul>
</details>
<details>
<summary>ElephantSqlDB® SQL Basic Level</summary>
<ul>
<li><a href="#sql-selecting-data">Step 1. SQL Selecting Data</a></li>
<li><a href="#sql-select-joining-data">Step 2. SQL Select Joining Data</a></li>
<li><a href="#sql-select-sub-querying-data">Step 3. SQL Select Sub-Querying Data</a></li>
<li><a href="#sql-inserting-data">Step 4. SQL Inserting Data</a></li>
<li><a href="#sql-updating-data">Step 5. SQL Updating Data</a></li>
<li><a href="#sql-deleting-data">Step 6. SQL Deleting Data</a></li>
<li><a href="#sql-filter-conditions">Step 7. SQL Filter Conditions</a></li>
<li><a href="#sql-boolean-operation">Step 8. SQL Boolean Operations</a></li>
</ul>
</details>
<details>
<summary>ElephantSqlDB® SQL Intermediate Level</summary>
<ul>
<li><a href="#sql-calculated-fields">Step 1. SQL Calculated Fields</a></li>
<li><a href="#sql-aggregate-functions">Step 2. SQL Aggregate Functions</a></li>
</ul>
</details>
<details>
<summary>ElephantSqlDB® SQL Advanced Level</summary>
<ul>
<li><a href="#sql-complex-table-extensions-cte">SQL Complex Table Extensions (CTE)</a></li>
</ul>
</details>
<details> <summary>ElephantSqlDB® SQL AI Client</summary> <ul> <li><a href="#4-the-elephantsqldb-sql-api-client">Step 1. The ElephantSqlDB® SQL API Client</a></li> <li><a href="#required-interfaces">Step 2. Required Interfaces</a></li> <li><a href="#code-example">Step 3. Code Example Support</a></li> </ul> </details>
<details> <summary>ElephantSqlDB® SQL AI Vector Search</summary> <ul> <li><a href="#1-ai-vector-search-and-embeddings-support">Step 1. AI Vector Search and Embeddings Support</a></li> </ul> </details>
<details> <summary>ElephantSqlDB® Document Database Support</summary> <ul> <li><a href="#5-document-database-support">Step 1. How to Store Documents</a></li> </ul> </details>
</nav>
<br>
ElephantSqlDB® is the next evolution of the popular NoSQL databases like PostgreSQL, MySQL and MongoDB we are all too familiar with. Until now, the performance of these popular databases was dependent on the underlying hardware for performance.
Today, ElephantSqlDB® is the first asymptotic database that leverages proprietary quantum computing algorithms to create a new database architecture that is responsible for superior performance instead of the expensive hardware, alone!
Using AI, ElephantSqlDB® is compatible with not only PostgreSQL but the following 13 other SQL dialects! <br><br>
- Snowflake
- MS SQL dialect
- MySQL dialect
- PostgreSql
- SQLite dialect
- MongoDB dialect
- DynamoDB dialect
- Generic SQL dialect
- ANSI SQL dialect
- Oracle/PL-SQL
- BigQuery SQL dialect
- ClickHouse SQL dialect
- DuckDb SQL dialect
- Hive SQL dialect
- Redshift SQL dialect
<br>
Getting Started!
Step 1. ElephantSqlDB® Welcome Email with Database Credits
ElephantSqlDB® is desinged to be simple, fast and affordable! One of the first email you should have received is the initial acknowledgment email with complimentary database credits. This email will provide you with a complimentary coupon code that you can use to sign-up for a trial and applying a discount. The trial is free for 7-days. After the 7-days has expired, the database credits will automatically provide savings while you continue to play with ElephantSqlDB®
Step 2. ElephantSqlDB® Credentials Email
Once you have signed-up for a subscription, you should have received the following automated email with credentials that you will need in-order to login to the SQL Management Portal.
Step 3. Accessing the ElephantSqlDB® Portal
Accessing the ElephantSqlDB® portal can be accessed in one of two ways.
- The first way is to use the hyperlink at the bottom of the credentials email.
- The second way is to use the website to login to the portal.
Please observe and follow the links to access the ElephantsqlDB® portal where you can manage your subscriptions as well as access the database portal.
- Once logged into the ElephantSqlDB® portal you can use the following link to access the ElephantSqlDB® SQL Management Portal
- From the ElephantSqlDB® portal you can also use the following link to manage your ElephantSqlDB® subscription.
Step 4. ElephantSqlDB® SQL Management Portal Registration
Once you have followed the links in the email containing your credentials and clicked the link to the portal, you will need to login using the credentials provided by ElephantSqlDB® when logging for the first time, you will need to provide some initial registration information in-order for ElephantSqlDB® to setup your Workspace. This information includes the following that should have been contained in the credentials email:
- Company Name
- API Token
- Username
- Password
Step 5. Logging Into ElephantSqlDB®
Now that you are fully registered, ElephantSqlDB® has created your Workspace which allows you to login using the following screen. From the main login screen you can (optionally) reset your registration. Resetting your registration can be used if and when your logins credentials get corrupted. Resetting your registration should be done as a last resort as you will need to ensure that you have access to your email credentials.
<br>
The ElephantSqlDB® SQL Management Portal
The ElephantSqlDB® Portal operates as a SQL Management Tool. From the Portal this can build and import databases in addition to adding and editing tables and any associated schema.
<br>
Creating a new Database
Now that you are logged into ElephantSqlDB® one of the first things you will want to do is to create a new database. Located in the upper right-hand of the ElephantSqlDB® SQL Management Portal is the main menu. On the main menu you will find the option to "Create New Database". Once you have created a new database you should see the new database name located in the database viewer located to the left of the screen.
Building your Database
Now that you created a new database you will need to build its tables and schema. ElephantSqlDB® provides two simple ways to build your database. The first approach is to use the Visual Schema Designer by (first) selecting the newly created database from the database viewer and then by selecting the "Edit Selected Database" option from the main menu. Once in the Visual Schema Designer you can create tables and add fields (columns) as well as create foreign key constraints between tables. Once done making changes you MUST save your changes before returning to the main screen.
Importing an Existing Database
If you already have a database supported by ElephantSqlDB® you can opt to import that database schema along with its tables and schema as well as import that actual data by using the "Data Migration" option from the main menu. From the Data Migration screen, simply locate and select the source database you are migrating from and enter your authentication details in-order to connect to that source database.
Importing Database Schema
Now that you have successfully connected to your source database, you will need to migrate the schema in-order to import all of the tables and fields (Columns) and foreign key constraints.
Confirming Imported Schema
Once the migration process has completed, you will be taken to the Visual Schema Editor to confirm the results before proceeding. Once satisfied with the results, simply save your work and proceed to "Import Data" step located in the upper right-hand of the screen.
Importing Data
Regardless of whether you have built your database manually or imported your data, ElephantSqlDB® allows you to import data from a source database by using .CSV files exported by your source database which get read into ElephantSqlDB® which is much faster than ready row by row from your source database in-order to get data into ElephantSqlDB®. On this screen, simply select all of the .CSV files to be imported into your newly built ElephantSqlDB® database.
Updating your Workspace
ElephantSqlDB® allows you to setup Workspaces. A Workspace is a concept used to encapsulate all databases into one area. The use of a Workspace is useful as it allows multiple divisions, departments or groups within an organization to use ElephantSqlDB® without stepping on each other or eachother's data. To access your intially created Workspace, simple use the main menu to select the "Connection Manager" option. If more than one group is using ElephantSqlDB® all they need to change in the name of the "Default Workspace" in-order to have a separate area to store and access their databases.
Setting up Users
ElephantSqlDB® provides the ability to create and manage user. The screen can be accessed by selecting the "User Management" option from the main menu.
User Management
ElephantSqlDB® allows users created within the User Management screen to management their own password and or activate multi-factor authentication if required.
Restoring from Daily Backups
ElephantSqlDB® automatically creates daily backups in the event restoring from that backup becomes necessary. To access this screen select the "Restore from Backup" option from the main menu.
<br> <br>
1. ElephantSqlDB® SQL Basic Level
SQL Selecting Data
ElephantSqlDB® support most SQL dialects. However, there are some slight nuances to constructing filter conditions that make dealing with ElephantSqlDB® much easier and intuitive. ElephantSqlDB® supports most SQL dialects including T-SQL and PostgreSql.
More importantly, the ElephantSqlDB® can be used to write and execute SQL query statements to review results. Once written, the SQL can be used within any application that integrates the ElephantSqlDB® API Client to pass through SQL statement(s) written in the the ElephantSqlDB® Portal.
The following is an example of a simple SQL select statement with a basic filter condition that returns all fields using a wildcard "*".
select * from api_key ak where ak.environment = 'SAAS'
The following is an example of a simple SQL select statement with a basic filter condition that uses projection to return the following specific fields: ak.user_auth_id, ak.environment, ak.created_date.
In addition to using projection to return specific fields, ElephantSqlDB® supports the use of aliases. In the following examples "ak" is used as an alias for the table api_key.
select
ak.user_auth_id,
ak.environment,
ak.created_date from api_key ak where ak.environment = 'SAAS'
<br>
SQL Select Joining Data
ElephantSqlDB® supports joins between tables. As with simple SQL select statements, joins (also) support projects and aliases. In the following example, ElephantSqlDB® uses projection to retrieve data from the api_key table using the "ak" alias and the app_user table using the "au" alias to retrieve ak.user_auth_id , au.id , au.user_name, au.first_name, au.last_name. Joins provide the ability to combine the columns of multiple tables in SQL results. Joins typically consume large amounts of compute resources but are light weight using ElephantSqlDB®.
select
ak.user_auth_id ,
au.id ,
au.user_name,
au.first_name,
au.last_name
from api_key ak
join app_user au on ak.user_auth_id = au.id
where ak.environment = 'SAAS'
<br>
SQL Select Sub-Querying Data
The following is an example of a simple SQL select statement that incorporates a sub-query. A sub-query is an alternative to joins that allow you to conduct quick look ups in-order to determine if results should or should not be returned..
SELECT w.user_auth_id
FROM api_key w
WHERE w.user_auth_id IN
(SELECT id from app_user WHERE username LIKE atrader111);
<br>
SQL Inserting Data
The following screenshot shows the data before the inserting of data.
The following is an example of a simple SQL statement to insert data. The following screenshot shows the data after the inserting of data.
INSERT INTO api_key
(id, user_auth_id, environment , key_type, created_date)
values (100ABCD, 100, paas , api , 2025-09-05 04:31:24);
<br>
The following screenshot shows the data after the inserting of data.
<br>
SQL Updating Data
The following screenshot shows the data before the update of data.
The following is an example of a simple SQL statement to update data. The following screenshot shows the data before the update of data.
UPDATE api_key
SET id = 100ABCD , key_type = api100
WHERE user_auth_id = 101
<br>
The following screenshot shows the data after updating the data.
SQL Deleting Data
The following screenshot shows the data before the deleting of data.
The following is an example of a simple SQL statement to delete data. The following screenshot shows the data after the deleting of data.
DELETE FROM api_key where user_auth_id = 100
<br>
The following screenshot shows the data after deleting data.
<br>
<br>
SQL Filter Conditions
ElephantSqlDB® supports a wide range of filter conditions. The following table represents the various filter conditions supported.
<small>Operation</small> | <small>Description</small> | <small>Example</small> | <small>Notes</small> |
---|---|---|---|
<small>Regexp</small> | <small>Regular expressions</small> | <small>ie: Match the lastname that begins with the letter "L". See the "Regular Expressions for more details visit: Regex Link."</small> | |
<small>FuzzyMatch</small> | <small>AI pattern match</small> | <small>ie: Match the lastname using artificial intelligence to find nuances in spelling.”</small> | |
<small>Gt, Gte</small> | <small>Greater than or equal.</small> | ||
<small>Le, Lte</small> | <small>Less than or less than or equal.</small> | ||
<small>Between</small> | <small>Between two values.</small> | ||
<small>Inq, Nin</small> | <small>In or not inv an array of values.</small> | ||
<small>Eq</small> | <small>Equal.</small> | ||
<small>Neq</small> | <small>Not equal.</small> | ||
<small>Like, NLike</small> | <small>Like or not like a value.</small> | <small>For example, where environment LIKE = SAAS will NOT return data if the data is 'saas'. LIKE is case sensitive. Therefore, you MUST filter by the string with its correct case.</small> | |
<small>ILike, NiLike</small> | <small>Case insensitive like and not like.</small> | <small>For example, where environment LIKE = SAAS will return data regardless of the case of the data being 'saas' or 'SAAS'. ILIKE and NILIKE are NOT case sensitive. Therefore, you only have to search by the correct string without concerning yourself with the case.</small> |
<br>
SQL Boolean Operation
ElephantSqlDB® supports the basic boolean operation. The following table represents the various boolean operations supported.
<small>Boolean Operation</small> | <small>Description</small> | <small>Example</small> | <small>Notes</small> |
---|---|---|---|
<small>Or / AND</small> | <small>Logical OR / AND</small> | <small>Filter conditions combine multiple filter conditions by adding an optional "AND" "OR" boolean operator to the end of each filter.</small> |
<br>
2. ElephantSqlDB® SQL Intermediate Level
ElephantSqlDB® supports the use of calculated fields. Calculated fields are invaluable when needing to conduct common mathematical functions of a tables column values. While table exist as either column-based or row-based, ElephantSqlDB® dynamically switches from a row-based architecture to a column-based architecture when calculated fields are used. This ability to switch dynamically allows ElephantSqlDB® to not suffer in performance when using calculated fields. The following is a list of the supported calculated fields.
SQL Calculated Fields
1. COUNT(*)
Calculates the total number of rows in a select statement.
1. SUM()
Calculates the sum total of a column in a select statement.
1. AVG()
Calculates the average value of a column in a select statement.
1. STD()
Calculates the standard deviation of a column in a select statement.
1. MIN()
Calculates the minimum value of a column in a select statement.
1. MAX()
Calculates the maximum value of a column in a select statement.
1. SINE()
Calculates the sine wave of a column in a select statement.
1. COSINE()
Calculates the cosine wave of a column in a select statement.
- The following is a comprehensive example of how to use these calculated fields in ElephantSqlDB®.
SELECT
count(*) as rowcount ,
MIN(user_auth_id) as MinRow ,
MAX(user_auth_id) as MaxRow ,
SUM(user_auth_id) as SumRow ,
STD(user_auth_id) as STDRow ,
SINE(user_auth_id) as SineRow ,
COSINE(user_auth_id) as CosineRow
FROM api_key w
<br>
SQL Aggregate Functions**
ElephantSqlDB® supports the aggregation of data through the following aggregate functions. Aggregate functions allow you to "roll-up" the rows or order the rows.
<small>Aggregate Function</small> | <small>Description</small> | <small>Example</small> | <small>Notes</small> |
---|---|---|---|
<small>Order by</small> | <small>Logical OR / AND</small> | <small>Sort the query results in ascending (ASC) or descending (DESC) order for a specific field. ie: select * from api_key where environment = 'DEV' order by application_name DESC.</small> | |
<small>Group by</small> | <small>Use this aggregate function to roll up the results on a particular column. ie: select * from api_key where environment = 'DEV' group by environment.</small> |
- The following is a comprehensive example of how to use these aggregate functions in ElephantSqlDB®.
select * from api_key order by user_auth_id DESC
select * from api_key group by environment
<br>
3. ElephantSqlDB® SQL Advanced Level
SQL Complex Table Extensions (CTE)
ElephantSqlDB® also supports complex table extensions commonly referred to as CTEs. CTEs are some of the most advanced SQL statements as they incorporate query aliases which can aide in making code easier to write but difficult to read.
The following is an example of an advanced SQL select statement with a CTE.
WITH Top10HenryWells AS (
SELECT id
from app_user WHERE username LIKE atrader100
)
SELECT w.user_auth_id , w.created_date , w.environment
FROM api_key w
WHERE w.user_auth_id IN (SELECT id FROM Top10HenryWells)
<br>
4. The ElephantSqlDB® SQL API Client
As with most databases, ElephantSqlDB® provides an Application Program Interface (API) that can be used to leverage ElephantSqlDB® within your applications. The ElephantSqlDB® API is available as a Nuget package under the name ElephantSqlDBClient and can be obtained via ElephantSqlDBClient-Nuget-Link.
When using the ElephantSqlDB® API you must implement the required interface on all of your strongly typed data objects when using passing in objects as opposed to strings (JSON). The ElephantSqlDB® API allows you to interact with your data as a strongly typed object or as a JSON string.
Required Interfaces
- When using a strongly typed object you MUST implement the CommonInterfaces class. When using JSON string save data, you are not required to implement the CommonInterfaces class. This class is found within the ElephantSqlDBClient client via our Nuget package.
Code Example
ElephantSqlDB® uses a concept of Workspaces to hold all databases. In turn, your databases hold your specific tables.
A Workspace can be setup by company organization , department or division. By using Workspaces, users can leverage one license for their entire operation without purchasing a separate license!
private IElephantSqlDBAPIService _client1 = default(IElephantSqlDBAPIService);
private static ElephantSqlDBApiFactory _elephantSqlDBApiServiceFactory;
private static string _elephantSqlDBApiBaseUri;
private static string _elephantSqlDBApiToken;
private static string _elephantSqlDBApiRoles;
private static string _elephantSqlDBUserEmail;
private static string _elephantSqlDBTenantId;
private static string _elephantSqlDBWorkspacePreface;
private static string _elephantSqlDBEncryption;
private static string _elephantSqlDBWorkspaceName;
private static bool _elephantSqlDBUseWebSockets;
private static Int32 _elephantSqlDBTimeOut;
private static Int32 _maxConnections;
private static Int32 _maxRecordsReturned;
private static Int32 _asyncScale;
private static string _hostRegistration;
/*/
* Initialize variables
/*/
_elephantSqlDBApiBaseUri = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBApiBaseUri");
_elephantSqlDBApiToken = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBApiToken");
_elephantSqlDBApiRoles = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBApiRoles");
_elephantSqlDBUserEmail = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBUserEmail");
_elephantSqlDBTenantId = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBTenantId");
_elephantSqlDBEncryption = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBEncryption");
_elephantSqlDBWorkspacePreface = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBWorkspacePreface");
_elephantSqlDBLedgerName = string.Format("{0}", StartupContext.Configuration?.GetValue<string>("_elephantSqlDBWorkspaceName"));
_elephantSqlDBUseWebSockets = StartupContext.Configuration.GetValue<bool>("ElephantSqlDBUseWebSockets");
_elephantSqlDBTimeOut = StartupContext.Configuration.GetValue<Int32>("ElephantSqlDBTimeOut");
_maxConnections = StartupContext.Configuration.GetValue<Int32>("ElephantSqlDBMaxConncetions");
_maxRecordsReturned = StartupContext.Configuration.GetValue<Int32>("ElephantSqlDBMaxRecordsReturned");
_hostRegistration = StartupContext.Configuration.GetValue<string>("ElephantSqlDBRegistrationHost");
_asyncScale = StartupContext.Configuration.GetValue<Int32>("ElephantSqlDBAsyncScale");
/*/
* Initialize Client API Factory
/*/
_elephantSqlDBApiServiceFactory = new ElephantSqlDBApiFactory(
_maxConnections,
_elephantSqlDBApiToken,
_elephantSqlDBApiRoles,
_elephantSqlDBUserEmail,
_elephantSqlDBTenantId,
_elephantSqlDBWorkspacePreface,
_elephantSqlDBworkspaceName,
_elephantSqlDBApiBaseUri,
_maxRecordsReturned,
_elephantSqlDBUseWebSockets,
asyncScale: _asyncScale);
/*/
* Create ElephantSqlDB API Client
/*/
_client1 = _elephantSqlDBApiServiceFactory.GetApiClient();
/*/
* Handle registration of user credentials
/*/
AuthStatus loginStatus;
UserLoginResponseDto loginDetails;
AuthStatus registrionResponseMessage;
UserRegistrationResponseDto registrionResponse;
if (authMessage == AuthStatus.CredentialsNotFound)
{
(registrionResponseMessage, registrionResponse) = _client1.RegisterNewUserAsync(
_elephantSqldBBUserEmail,
"Passw0rd",
"Default.FirstName",
"Default.MiddleName",
"Default.LastName",
"Default.loginDetails.Phone",
false).Result;
authMessage = await _client1.IsCredentialsValid();
}
if (authMessage == AuthStatus.NoTenantDatabaseFound)
{
var newDatabase = _client1.CreateDatabaseAsync(_client1.GetLedgerName()).Result;
if (!string.IsNullOrEmpty(newDatabase.errorMessage))
{
Debug.WriteLine(string.Format(newDatabase.errorMessage));
return;
}
authMessage = await _client1.IsCredentialsValid();
}
if (authMessage == AuthStatus.Success)
{
/*/
* Example : Inserting data
/*/
string SqlInsertStatement = @"
INSERT INTO api_key
(id, user_auth_id, environment , key_type, created_date)
values (100ABCD, 1, paas , api , 2025-09-05 04:31:24)";
Task<AuthStatus> write = _client1.InsertSQLRecordsAsync<string>(SqlInsertStatement, DatabaseName: "postgresql_postgres_public");
/*/
* Example : Updating data
/*/
string SqlUpdateStatement = @"
UPDATE api_key
SET id = 100ABCD ,
key_type = api100
WHERE user_auth_id = 1";
Task<AuthStatus> update = _client1.UpdateSQLRecordsAsync<string>(SqlUpdateStatement, DatabaseName: "postgresql_postgres_public");
/*/
* Example : Selecting data
/*/
String SqlSelectStatement = $@"
select count(*) as rowcount,
id,
created_date from api_key where user_auth_id = 1";
(AuthStatus authStatus, List<string> results, PaginationDTO paginationDetails123) = await _client1.SelectSQLRecordsAsync<string>(
SqlSelectStatement,
DatabaseName: "postgresql_postgres_public",
null);
/*/
* Example : Deleting data
/*/
string SqlDeleteStatement = @DELETE FROM api_key where user_auth_id = 1";
Task<AuthStatus> delete = await _client1.DeleteSQLRecordsAsync<string>(SqlDeleteStatement, DatabaseName: "postgresql_postgres_public");
}
1. AI Vector Search and Embeddings Support
As a multi-type database, ElephantSqlDB® (also) supports storing and retrieving embeddings for AI-related search functions. In-order to support storing and searching for embeddings, ElephantSqlDB® provides some useful helper functions.
/*/
* Create vector search string
/*/
private IElephantSqlDBAPIService _client1 = default(IElephantSqlDBAPIService);
private static ElephantSqlDBApiFactory _elephantSqlDBApiServiceFactory;
private static string _elephantSqlDBApiBaseUri;
private static string _elephantSqlDBApiToken;
private static string _elephantSqlDBApiRoles;
private static string _elephantSqlDBUserEmail;
private static string _elephantSqlDBTenantId;
private static string _elephantSqlDBWorkspacePreface;
private static string _elephantSqlDBEncryption;
private static string _elephantSqlDBWorkspaceName;
private static bool _elephantSqlDBUseWebSockets;
private static Int32 _elephantSqlDBTimeOut;
private static Int32 _maxConnections;
private static Int32 _maxRecordsReturned;
private static Int32 _asyncScale;
private static string _hostRegistration;
/*/
* Initialize variables
/*/
_elephantSqlDBApiBaseUri = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBApiBaseUri");
_elephantSqlDBApiToken = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBApiToken");
_elephantSqlDBApiRoles = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBApiRoles");
_elephantSqlDBUserEmail = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBUserEmail");
_elephantSqlDBTenantId = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBTenantId");
_elephantSqlDBEncryption = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBEncryption");
_elephantSqlDBWorkspacePreface = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBWorkspacePreface");
_elephantSqlDBLedgerName = string.Format("{0}", StartupContext.Configuration?.GetValue<string>("_elephantSqlDBWorkspaceName"));
_elephantSqlDBUseWebSockets = StartupContext.Configuration.GetValue<bool>("ElephantSqlDBUseWebSockets");
_elephantSqlDBTimeOut = StartupContext.Configuration.GetValue<Int32>("ElephantSqlDBTimeOut");
_maxConnections = StartupContext.Configuration.GetValue<Int32>("ElephantSqlDBMaxConncetions");
_maxRecordsReturned = StartupContext.Configuration.GetValue<Int32>("ElephantSqlDBMaxRecordsReturned");
_hostRegistration = StartupContext.Configuration.GetValue<string>("ElephantSqlDBRegistrationHost");
_asyncScale = StartupContext.Configuration.GetValue<Int32>("ElephantSqlDBAsyncScale");
/*/
* Initialize Client API Factory
/*/
_elephantSqlDBApiServiceFactory = new ElephantSqlDBApiFactory(
_maxConnections,
_elephantSqlDBApiToken,
_elephantSqlDBApiRoles,
_elephantSqlDBUserEmail,
_elephantSqlDBTenantId,
_elephantSqlDBWorkspacePreface,
_elephantSqlDBworkspaceName,
_elephantSqlDBApiBaseUri,
_maxRecordsReturned,
_elephantSqlDBUseWebSockets,
asyncScale: _asyncScale);
/*/
* Create ElephantSqlDB API Client
/*/
_client = _elephantSqlDBApiServiceFactory.GetApiClient();
/*/
* Handle registration of user credentials
/*/
AuthStatus loginStatus;
UserLoginResponseDto loginDetails;
AuthStatus registrionResponseMessage;
UserRegistrationResponseDto registrionResponse;
if (authMessage == AuthStatus.CredentialsNotFound)
{
(registrionResponseMessage, registrionResponse) = _client.RegisterNewUserAsync(
_elephantSqldBBUserEmail,
"Passw0rd",
"Default.FirstName",
"Default.MiddleName",
"Default.LastName",
"Default.loginDetails.Phone",
false).Result;
authMessage = await _client.IsCredentialsValid();
}
if (authMessage == AuthStatus.NoTenantDatabaseFound)
{
var newDatabase = _client.CreateDatabaseAsync(_client.GetLedgerName()).Result;
if (!string.IsNullOrEmpty(newDatabase.errorMessage))
{
Debug.WriteLine(string.Format(newDatabase.errorMessage));
return;
}
authMessage = await _client.IsCredentialsValid();
}
if (authMessage == AuthStatus.Success)
{
Vector<Int32> vector = new Vector<Int32>();
vector.AddVector(new int[] { 8, 2, 3, 4, 5 });
string vectorString = ElephantSqlDBAPIHelper.ConvertVectorToString<Int32>(vector);
Embeddings<Vector<Int32>, Int32> embedding = new Embeddings<Vector<Int32>, Int32>();
embedding.AddEmbedding(new[,]
{
{ new Vector<Int32>(new Int32[] { 1, 2, 3, 4, 5 }) },
{ new Vector<Int32>(new Int32[] { 5, 6, 3, 8, 7 }) },
{ new Vector<Int32>(new Int32[] { 3, 7, 3, 9, 1 }) }
}
);
string embeddingsData = embedding.GetEmbeddingString();
if (IsValidJson(embeddingsData) == true)
{
var deserializedEmbeddings = JsonConvert.DeserializeObject(embeddingsData);
/*/
* Check to see if the deserialized string is an array.
/*/
if (deserializedEmbeddings is JArray)
{
/*/
* Convert the string to an array and strip off the starting and ending brackets.
/*/
string[] embeddingsArray = JArray.Parse(embeddingsData).ToString().Split("\r\n").Skip(1).SkipLast(1).ToArray();
}
/*/
* Example : Selecting embeddings data
/*/
String SqlSelectStatement = $@"
select *
from api_key where user_auth_id VECTORSEARCH {embeddingsData}";
(AuthStatus authStatus, List<string> results, PaginationDTO paginationDetails123) = await _client.SelectSQLRecordsAsync<string>(
SqlSelectStatement,
DatabaseName: "postgresql_postgres_public",
null);
}
}
5. Document Database Support
As a multi-type database, ElephantSqlDB® (also) provides support full support for document database functions.
1. How to Store Documents
/*/
* Document Database Example
/*/
private IElephantSqlDBAPIService _client1 = default(IElephantSqlDBAPIService);
private static ElephantSqlDBApiFactory _elephantSqlDBApiServiceFactory;
private static string _elephantSqlDBApiBaseUri;
private static string _elephantSqlDBApiToken;
private static string _elephantSqlDBApiRoles;
private static string _elephantSqlDBUserEmail;
private static string _elephantSqlDBTenantId;
private static string _elephantSqlDBWorkspacePreface;
private static string _elephantSqlDBEncryption;
private static string _elephantSqlDBWorkspaceName;
private static bool _elephantSqlDBUseWebSockets;
private static Int32 _elephantSqlDBTimeOut;
private static Int32 _maxConnections;
private static Int32 _maxRecordsReturned;
private static Int32 _asyncScale;
private static string _hostRegistration;
/*/
* Initialize variables
/*/
_elephantSqlDBApiBaseUri = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBApiBaseUri");
_elephantSqlDBApiToken = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBApiToken");
_elephantSqlDBApiRoles = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBApiRoles");
_elephantSqlDBUserEmail = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBUserEmail");
_elephantSqlDBTenantId = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBTenantId");
_elephantSqlDBEncryption = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBEncryption");
_elephantSqlDBWorkspacePreface = StartupContext.Configuration?.GetValue<string>("ElephantSqlDBWorkspacePreface");
_elephantSqlDBLedgerName = string.Format("{0}", StartupContext.Configuration?.GetValue<string>("_elephantSqlDBWorkspaceName"));
_elephantSqlDBUseWebSockets = StartupContext.Configuration.GetValue<bool>("ElephantSqlDBUseWebSockets");
_elephantSqlDBTimeOut = StartupContext.Configuration.GetValue<Int32>("ElephantSqlDBTimeOut");
_maxConnections = StartupContext.Configuration.GetValue<Int32>("ElephantSqlDBMaxConncetions");
_maxRecordsReturned = StartupContext.Configuration.GetValue<Int32>("ElephantSqlDBMaxRecordsReturned");
_hostRegistration = StartupContext.Configuration.GetValue<string>("ElephantSqlDBRegistrationHost");
_asyncScale = StartupContext.Configuration.GetValue<Int32>("ElephantSqlDBAsyncScale");
/*/
* Initialize Client API Factory
/*/
_elephantSqlDBApiServiceFactory = new ElephantSqlDBApiFactory(
_maxConnections,
_elephantSqlDBApiToken,
_elephantSqlDBApiRoles,
_elephantSqlDBUserEmail,
_elephantSqlDBTenantId,
_elephantSqlDBWorkspacePreface,
_elephantSqlDBworkspaceName,
_elephantSqlDBApiBaseUri,
_maxRecordsReturned,
_elephantSqlDBUseWebSockets,
asyncScale: _asyncScale);
/*/
* Create ElephantSqlDB API Client
/*/
_client = _elephantSqlDBApiServiceFactory.GetApiClient();
/*/
* Handle registration of user credentials
/*/
AuthStatus loginStatus;
UserLoginResponseDto loginDetails;
AuthStatus registrionResponseMessage;
UserRegistrationResponseDto registrionResponse;
if (authMessage == AuthStatus.CredentialsNotFound)
{
(registrionResponseMessage, registrionResponse) = _client.RegisterNewUserAsync(
_elephantSqldBBUserEmail,
"Passw0rd",
"Default.FirstName",
"Default.MiddleName",
"Default.LastName",
"Default.loginDetails.Phone",
false).Result;
authMessage = await _client.IsCredentialsValid();
}
if (authMessage == AuthStatus.NoTenantDatabaseFound)
{
var newDatabase = _client.CreateDatabaseAsync(_client.GetLedgerName()).Result;
if (!string.IsNullOrEmpty(newDatabase.errorMessage))
{
Debug.WriteLine(string.Format(newDatabase.errorMessage));
return;
}
authMessage = await _client.IsCredentialsValid();
}
if (authMessage == AuthStatus.Success)
{
string existingHashCode = string.Empty;
string blockName = Guid.NewGuid().ToString();
DatabaseModel data = new DatabaseModel() { Name = tableRecordName, Tables = new List<TableModel>() };
_client.SaveToDatabaseWithNoResponse<DatabaseModel>(dataContext: data, queryPatterns: new List<List<string>>(), queryPatternFunction: new List<string>(), nameOfBlock: tableRecordName, blockExistingHashKey: existingHashCode);
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- DynamicExpresso.Core (>= 2.16.1)
- Microsoft.AspNetCore (>= 2.2.0)
- Microsoft.AspNetCore.SignalR.Client (>= 7.0.2)
- Microsoft.AspNetCore.SignalR.Protocols.MessagePack (>= 7.0.2)
- Newtonsoft.Json (>= 13.0.2)
- ServiceStack (>= 6.0.2)
- ServiceStack.Interfaces (>= 6.0.2)
- System.Collections.Concurrent (>= 4.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated | |
---|---|---|---|
1.0.151 | 153 | 10/4/2025 | |
1.0.149 | 154 | 10/4/2025 | |
1.0.146 | 144 | 9/7/2025 | |
1.0.145 | 179 | 9/5/2025 | |
1.0.144 | 174 | 9/5/2025 | |
1.0.143 | 175 | 9/4/2025 | |
1.0.142 | 178 | 9/4/2025 | |
1.0.141 | 178 | 9/4/2025 | |
1.0.140 | 214 | 8/30/2025 | |
1.0.139 | 209 | 8/26/2025 | |
1.0.138 | 208 | 8/26/2025 | |
1.0.137 | 187 | 8/25/2025 | |
1.0.136 | 115 | 8/24/2025 | |
1.0.135 | 108 | 8/24/2025 | |
1.0.134 | 113 | 8/24/2025 | |
1.0.133 | 162 | 8/11/2025 | |
1.0.132 | 160 | 8/11/2025 | |
1.0.131 | 238 | 8/7/2025 | |
1.0.130 | 245 | 8/7/2025 | |
1.0.129 | 255 | 8/6/2025 | |
1.0.128 | 242 | 8/6/2025 | |
1.0.127 | 245 | 8/5/2025 | |
1.0.126 | 231 | 8/5/2025 | |
1.0.125 | 121 | 7/31/2025 | |
1.0.124 | 123 | 7/30/2025 | |
1.0.123 | 147 | 7/28/2025 | |
1.0.122 | 338 | 2/20/2025 | |
1.0.121 | 259 | 1/18/2025 | |
1.0.120 | 127 | 1/18/2025 | |
1.0.119 | 133 | 1/18/2025 | |
1.0.118 | 209 | 1/17/2025 | |
1.0.117 | 237 | 1/9/2025 | |
1.0.116 | 362 | 10/16/2024 | |
1.0.115 | 151 | 10/16/2024 | |
1.0.114 | 148 | 10/16/2024 |
ElephantSqlDB Client for .NetCore 6.0 and above