BG Database (inMemory database | Excel/Google Sheets syncing | CodeGen | Save/Load support)

Hello! I’m considering buying this for our company, to import existing Google Sheets of game data variables (prices and other such variables) into a database-like structure (which I see that this can do with classes).

I have a few questions I cannot find the answer to in the documentation:

  1. Whether it can somehow ignore certain rows of a sheet tab, like if I use the _id column setup and I have e.g. a row of headers every 40 lines, can I then just leave the _id field blank or is there a certain “ignore tag” I can use? The documents have been set up by designers to give a good overview, but the values are still mostly in a database-like structure; it’s just that there are some fluff-rows in certain places. (I see that Google Sheets doesn’t include completely empty rows, so we’ll make sure our fluff-rows have some value in some field; thanks for the note!).

  2. On the other axis, can I skip/ignore certain columns in certain sheet-tabs? Do I just leave the column name field blank to have them skipped?

  3. Will those ignored columns and rows persist in the Google Sheet if I export the data from the Unity editor to the Google Sheet, or does it replace the entire sheet structure? Either way, I guess the plan is to only make permanent changes via the Google Sheet and import from there; I don’t think we’d ever be exporting from Unity to the Google Sheet.

  4. Can I choose which axis to use as rows and columns, so I can have a sheet that becomes a table with a single entity holding all the values in column 1, each keyed to their variable-name in column 0 (which acts like a header-row).

  5. Any way to generate a custom table using custom keys mapped to specific cells of a sheet, in order to handle something like this (see image), without resorting to a looong row of values, which isn’t very neat for designers? In relation to question 4, it would be acceptable to have the axes flipped, so the values can at least extend downwards.

Hello, sorry for a little delay :sweat_smile:
The BGExcelImportGo script has Export() method, if you call it- all changes you made to database rows should be transferred to Excel file (if table/fields are included into Export settings).
BGExcelImportGo component is the one holding all Excel parameters and export parameters are accessed via “Export settings” button (please, see the screenshot under the spoiler)
Excel runtime export parameters

7955901--1019310--25.png

You can create a table dynamically in runtime, add required fields and rows.
Here is example of creating new table “DynamicTable” with 2 fields: “intField” (int) and “floatField” (float) and 2 rows
Creating new table in runtime

using BansheeGz.BGDatabase;
using UnityEngine;

public class Test : MonoBehaviour
{
    /// <summary>
    /// Example how to add new table dynamically in runtime
    /// </summary>
    private void Start()
    {
        //add new table
        BGMetaEntity dynamicTable = new BGMetaRow(BGRepo.I, "DynamicTable");
        //add intField(int) field
        BGFieldInt intField = new BGFieldInt(dynamicTable, "intField");
        //add floatField(float) field
        BGFieldFloat floatField = new BGFieldFloat(dynamicTable, "floatField");
       
        //first row
        BGEntity firstRow = dynamicTable.NewEntity();
        firstRow.Name = "First row";
        intField[firstRow.Index] = 1;
        floatField[firstRow.Index] = 1.1f;

        //second row
        BGEntity secondRow = dynamicTable.NewEntity();
        secondRow.Name = "Second row";
        intField[secondRow.Index] = 2;
        floatField[secondRow.Index] = 2.2f;
    }
}

7955901--1019319--27.png

Then you need to ensure that this new table is included into export settings.
There are 2 options available to include created table into export settings:

  1. The first option is to include all tables/fields.
    This is the easiest method and it does not require any additional steps- but it also means that all table/fields will be exported
    Just toggle on all three top level toggles (“Add missing”/“Remove orphaned”/“Update matching”) and all tables and fields will be automatically added to the export (including the ones, added dynamically in runtime)
    Export settings, including all tables/fields

7955901--1019316--26.png

  1. The second option- is to modify export settings in runtime
    Here is an example how to include table “Test” with all fields into export.
    If you need to selectively include only some fields into the export- please, let me know
    Adding “Test” table into export settings
using BansheeGz.BGDatabase;
using UnityEngine;

public class Test : MonoBehaviour
{
    //reference to excel manager
    public BGExcelImportGo excelManager;
    /// <summary>
    /// Example how to add "Test" table with all fields into export settings
    /// </summary>
    private void Start()
    {
        //database table
        BGMetaEntity table = BGRepo.I["Test"];
        //export settings
        BGMergeSettingsEntity exportSettings = excelManager.ExportSettings;

        // add new table to export settings
        BGMergeSettingsEntity.MetaSettings testTableSettings = exportSettings.Ensure(table.Id);
        //toggle on three parameters
        testTableSettings.AddMissing = testTableSettings.RemoveOrphaned = testTableSettings.UpdateMatching = true;
       
        //uncomment this line to export the data
        // excelManager.Export();
    }
}

If you have any issues implementing this concept- please, let me know- I could send you an example project

1 Like

Hello,

  1. Currently the only supported data layout format is the following:
    1.1) The first row contains the field names
    1.2) Rows, starting with the 2nd one, contain field values
  2. Empty rows (rows without any value under valid fields columns) will be ignored
  3. We could add some special tag, which could be used to skip rows even if some values are present
  4. Also, there are some settings, which can be used for ignoring certain rows.
    For example if you toggle off “add missing” and “remove orphaned” toggles- all rows without valid _id value will be ignored during import or export

If the column name is empty or can not be mapped to a database field- the whole column will be ignored

  1. The structure will be preserved
  2. Even if you export data from Unity Editor to GoogleSheets- the ignored columns and rows should not be overwritten
    Before writing values to GoogleSheet, export procedure determines the target cells and skips the ignored ones

I think we could add support for such layout, but it’s hard to estimate how much time it can take

No, such feature is not currently supported unfortunately

If you are interested in evaluating our asset- please, send me a message using forum conversations or using our support email

1 Like

Thank you very much for your response! That information all helps a lot, actually.

I’m happy to say, that I already took the plunge and got 2 seats for us, and the asset is great! It’s only Google’s identification and credential service spiderweb that’s a hurdle when starting to use this asset, and your guides are mostly up-to-date with the steps needed, so thank you for those <3

One more thing, then: I’ve added a column on the far left of my Google Sheet, with a header named _id. When I import the structure of my sheet, it asks to include the _id field (but remove the underscore from the field name).
Should I:

  1. include it in the structure
  2. ignore it, and it’ll be filled into the sheet when I export data to it after importing data from it?

I guess the question is, do I have to manually link the _id field in my structure, or is it linked “automagically”? When/how do the ids get into my empty _id column in the sheet? The instructions just say to make sure the field is in the sheet. It doesn’t say whether it has to be all the way on the left or how to link it. At least not for Google Sheets.

EDIT: I tried omitting (ignore) the _id field on import, and then pressed Export to see if it would push the generated ids from the Id-column of the Meta to the _id column in the Google Sheet, and then I get this error:
"Unable to parse range: !A0:A0
7964811--1021221--2022-03-15 15_05_36-Window.png
…which I can’t make sense of, unless A0 means row 1, which I’m pretty sure it doesn’t?

This is the test document structure. Only the yellow ones will be included in the Meta, but what about that _id field?
7964811--1021227--upload_2022-3-15_15-13-59.png

1 Like

Hello, thank you for buying our asset!
I agree, that Google authentication is very confusing (especially OAuth 2.0), I hope there is a good reason behind this

You did the right thing by adding _id column
_id column should not come up in data extraction wizard cause it’s a system field, it’s a mistake we did, sorry
Disabling _id column should fix the error or alternatively use the attached package with a fix (_id column will be skipped)

Please, use “Data extraction wizard” to extract database structure (tables/fields) only, do not transfer rows with it
Data extraction wizard setup

7965534--1021263--33.png

Once the database structure is created
Database structure

7965534--1021266--34.png

Use an “export/import job” to transfer data.
Make sure to toggle on “update IDs on import” and include table(s) you want to transfer data for(they will be highlighted in green)
Transferring rows with a export/import job

7965534--1021269--35.png

After clicking on “Import” button, the rows should be transferred to the database, and GoogleSheets _id should be filled with the same values database has
import result

7965534--1021272--36.png

These IDs will be used to identify- to which database row Google sheet row is mapped

If you encounter any error during importing data- please, let me know and we will investigate this issue

7965534–1021260–BGDatabaseGoogleSheetsEditor_1.4.unitypackage (473 KB)

1 Like

This is all working perfectly! Absolutely stellar asset you guys have made!

1 Like

I forget if I asked this before- but is it possible to open multiple repo files at the same time.

No, it’s not possible unfortunately
You can open two database files using Merge tool and see the difference : https://www.bansheegz.com/BGDatabase/MergeTool/

on install

Unable to update following assemblies:Assets/BansheeGz/BGDatabase/Editor/Scripts/BGDatabaseEditor.dll (Name = BGDatabaseEditor, Error = -2147450735) (Output: C:\Users\S\AppData\Local\Temp\tmp54d6b453.tmp)

Could not execute because the application was not found or a compatible .NET SDK is not installed.
Possible reasons for this include:
  * You intended to execute a .NET program:
      The application 'C:/Program' does not exist.
  * You intended to execute a .NET SDK command:
      It was not possible to find any installed .NET SDKs.
      Install a .NET SDK from:
        https://aka.ms/dotnet-download
Assets/BansheeGz/BGDatabase/Scripts/BGDatabase.dll (Name = BGDatabase, Error = -2147450735) (Output: C:\Users\S\AppData\Local\Temp\tmp305da941.tmp)

Could not execute because the application was not found or a compatible .NET SDK is not installed.
Possible reasons for this include:
  * You intended to execute a .NET program:
      The application 'C:/Program' does not exist.
  * You intended to execute a .NET SDK command:
      It was not possible to find any installed .NET SDKs.
      Install a .NET SDK from:
        https://aka.ms/dotnet-download

UnityEditor.Scripting.APIUpdaterLogger:WriteErrorToConsole (string,object[])
UnityEditorInternal.APIUpdating.APIUpdaterManager:HandleAssemblyUpdaterErrors (System.Collections.Generic.IList`1<UnityEditorInternal.APIUpdating.AssemblyUpdaterUpdateTask>)
UnityEditorInternal.APIUpdating.APIUpdaterManager:UpdateAssemblies ()

Could not execute because the application was not found or a compatible .NET SDK is not installed.
Possible reasons for this include:

You use Unity 2022 beta, correct?
I think it is some issue with Unity API updater https://docs.unity3d.com/Manual/APIUpdater.html , which can not run on your computer properly for some reason
I DMed you a already upgraded package (upgraded with Unity 2022.1.0b14)- it should work properly without Unity API updater

Thanks (2022.1.0b14) yeah it works now

Our project update to v1.7.7. This error appear when open BG Database windows.We canot open old data any more.

BGException: Can not deserialize field ItemAttributeInfo.AttrType: enum type ChiefOfImmortal.Definition.Enum.AttributeType has wrong underlying type, expected System.Int32 found System.Byte !

Find your AttributeType enum definition in C# source file and remove : byte snippet
This should fix the error
8239938--1077399--78.png

“underlying type” refers to the type your enum is extended from.
There are 3 options- int (default type), short and byte
This error message “enum type ChiefOfImmortal.Definition.Enum.AttributeType has wrong underlying type, expected System.Int32 found System.Byte” means, that AttributeType enum was originally extended from int type, but later this type was changed to byte

Ok, got it.Thanks
By the way, we canont use enumbyte any more?In pre version,our project use many enumbyte,because we thought it will reduce the data persistence file size by using enumbyte.

enumByte and enumShort fields are still available

  1. For new fields, select appropriate enum field type in “Add field to [MetaName]” dialog
    Selecting enum type for new fields

8240025--1077408--79.png

  1. If you want to migrate existing enum field to new enum type without losing existing data- please follow the guide below.
    The guide is written for enum->enumByte migration and it can also be used for other types as well

The guide for changing enum underlying type starts here:
2.1) Backup your database just in case
2.2) Locate your enum in C# source files and create a copy with target enum type (in our case it’s byte).
Change a copy’s name by appending “Temp” postfix
enum type copy

8240025--1077411--80.png

2.3) Locate your enum field under “Configuration” tab and open “Change field type” dialog
Change field type dialog

8240025--1077414--81.png

2.4) Select enumByte as a new field type and set enum type name to your temp copy enum.
Click on “Change field type” button and save database.
change field type parameters

8240025--1077417--82.png

2.5) Switch back to your C# source file and change your enum underlying type to the target type (in our case it’s byte type)
changing enum underlying type

8240025--1077420--83.png

The guide is continuted in the next message…

…The guide (2nd part)

2.6) Switch back to the database window and change enum type from your temp enum copy (AttributeTypeTemp) to the actual type (AttributeType).
Save database
changing field’s enum type in database

2.7) Switch to you C# source file and delete temp enum
deleting temp enum

8240034--1077426--85.png

The end of the guide

Thanks. it’s migrate well follow your guide step

Hi BansheeGz. Do you have any documentation on funtion of default values ?I canot find it in BansheeGz

Hi!

We have added a section about “Default field value” here (at the very bottom of the page) https://www.bansheegz.com/BGDatabase/Misc/#defaultFieldValue
If you have any questions- please, let me know

How can I get out of ForEachEntity, I’d like to use return; or continue; or break; if possible

Thank you