generated from BHoM/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 1
Usage in Grasshopper
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.
You will usually require two components:
- The SqlAdaptor (BH.Adapter.SQL.SqlAdapter.SqlAdapter). The
server
will usually be set tolocalhost
. Thedatabase
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.
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.