Skip to content

GooseDBMS. Free cloud DBMS based on Google products

Notifications You must be signed in to change notification settings

gttrcr/GooseDBMS

Repository files navigation

GooseDBMS

GooseDBMS. Free cloud DBMS based on Google products

github

GooseDMBS was created to get around the problem of building cloud database-based applications. The data entry takes place through the automatic sending of a Google form. The solution is particularly useful for all those push only applications such as MQTT or one-way communications (weather stations, IoT devices, sending status data, ...). The entire solution does not require writing specific code but only configuring a file.

Usings

using Goose;
using Goose.Type.Config;
using Goose.Type.DBMS;

Example of goose.json Configuration file

Consider the following configuration file

{
  "ClientSecretFilePath": "client_secret.json",
  "ApiKey": null,
  "Tables": [
    {
      "Name": "list_of_devices_table",
      "Columns": [
        {
          "Entry": 467582135,
          "Value": "device_number",
          "Key": "th38sjj2",
          "Export":"item1"
        },
        {
          "Entry": 545400028,
          "Value": "mac_address",
          "Key": "0vbcgdv3",
          "Export":"item2"
        }
      ],
      "FormID": "582ufbefRRJT4t28h65h26jJg-hjh83HHFH36j6j",
      "PrefilledFormID": "ghjrkelkjwTHSKHJR54y52yTSHETRH25u25u-w5j5ju5STs55",
      "Dynamic": {              // this is a dynamic object
        "Domain":"database",    // this field is just an example
        "Policy": "tutygh5753", // this field is just an example
        "ID": 676758920656      // this field is just an example
      }
    }
  ]
}
Key Value Optional?
ClientSecretFilePath path of the json client secret file YES
ApiKey google ApiKey YES
Tables list of table object NO
Tables.Name name of the table NO
Tables.Columns list of columns for every table NO
Tables.FormID id of the form corresponding to the table YES
Tables.PrefilledFormID id of the prefilled form for the form corresponding to the table NO
Tables.Columns.Entry entry number corresponding to the prefilled field of the form NO
Tables.Columns.Value string value of the column (column name) NO
Tables.Columns.Key string representing the question id of the form NO
Tables.Dynamic a dynamic object used to store everything you will need to use GooseDBMS YES

The configuration file can be automatically generated by a utility function in GooseDBMS. Consider the following example

List<GooseConfigEntry<string>> gooseConfigEntries = new()
{
    new()
    {
        PrefilledUrl = "https://docs.google.com/forms/d/e/1FAIpQLS4250h2590gj1589j4wtwjUZWJc-urOdY3ehuxQA/viewform?usp=pp_url&entry.637106372=name&entry.680296813=surname",
        FormID = "1R2598h2984j2g4598jg298j590g82vjd-g5W9rrXI",
        Export = new() { "1", "2" },
        Dynamic = new(){{"Object", "db1"}}
    },
    new()
    {
        PrefilledUrl = "https://docs.google.com/forms/d/e/129845g2925g1jgu5hghjgh5kg15hg15g-g3QsA/viewform?usp=pp_url&entry.637276372=name&entry.600096813=surname&entry.611645835=email",
        FormID = "2459g82j495082j980gj249085jg20948jg09g82j",
        Export = new() { "A", "B", "C" },
        Dynamic = new(){{"Object", "db2"}}
    }
};
Config.CreateConfig("goose_eaziu.json", "client_secret.json", gooseConfigEntries, LogSeverity.Info);

The static function GooseConfig.CreateConfig takes as arguments

  1. the path of the configuration json file you want for your GooseDBMS application
  2. the path of the json client secret file
  3. the list of prefilled url for every form
  4. the list of form id

Pay attention that in GooseDBMS, every form is a table. When the goose_config.json is saved, then GooseDBMS instance can be created.

User application (client)

In the case of client application, the user can only just push data to DB. So, ClientSecretFilePath and FormID should be null and just PrefilledFormID will be used to create the link to push data.

User goose = new("goose_config_new.json");  //instance of GooseDBMS user
goose.Insert("tablename", new List<string>() { "colum1 value", "column2 value" });  //this equivalent to: INSERT INTO tablename (name, surname) VALUES ('column1 value', 'column2 value')

Owner application (server)

In the case of server application or master application, the user is able to push and pull data to DB. So ClientSecretFilePath and FormID must be not null and valid to create a Google service able to read form body and responses. In any case, the data entered into the database cannot be modified in form response but soon there will be the possibility of replacing previous data with updated data so as to also implement the update functionality as in a real database.

Owner goose = new("goose_config_new.json");  //instance of GooseDBMS owner
GooseTable? gooseTable = goose.Select("SELECT * FROM tablename WHERE name = 'some name value'");  //literally the sql SELECT statement
Owner.Insert("tablename", new List<string>() { "colum1 value", "column2 value" });  //this equivalent to: INSERT INTO tablename (name, surname) VALUES ('column1 value', 'column2 value')

goose.DataReceivedCallback = (gooseDB, previousGooseDB, differenceGooseDB) =>  //callback triggered by new data on DB
{
    Console.WriteLine(differenceGooseDB);
};

GooseDBMS library

Pack with

rm -rf bin
rm -rf obj
dotnet pack -c Release

Import locally with

dotnet add package GooseDBMS -s ../GooseDBMS/bin/Release

or with

dotnet add package GooseDBMS

Releases

No releases published

Packages

No packages published

Languages