You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
James Ramsden edited this page Dec 8, 2021
·
2 revisions
Below is a few examples of usage in Grasshopper. This list is far from complete - feel free to add your own!
Firstly, you will need to install SQL Server and Management Tool - see the installation tab.
Then you will need to set up your own database and tables from within the Management Tool - this is not currently possible directly with the SQL toolkit.
General setup
You will usually require two components:
The SqlAdaptor (BH.Adapter.SQL.SqlAdapter.SqlAdapter). The server will usually be set to localhost. The database is the name of the database you created in the Management Tool.
The Execute. This is the general execute method that can be found under BH.Adapter.Execute.
To actually interact with the database, we then need to insert an additional method into the command parameter.
Upsert with custom objects
BHoM components needed:
BH.oM.Adapters.SQL.UpsertCommand
BH.oM.CreateCustom (or your own choice in creating a BHoM CustomObject)
System.Type, then right-click to select the type of your primary key (usually System.int32)
Points to note:
The keys in the CustomObject items should map to the column names of your database table
Avoid column names of id in your database as this can create clashes within CustomObject creation.