# Revit- MySQL link

**URL:** <https://forum.dynamobim.com/t/revit-mysql-link/8272>\
**Category:** FAQ\
**Created:** [December 15, 2016, 8:57pm UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272 "2016-12-15T20:57:12Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![MOJTABA256](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@MOJTABA256](https://forum.dynamobim.com/u/MOJTABA256)\
**Post date:** [December 15, 2016, 8:57pm UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/1 "2016-12-15T20:57:13Z")

</div>

Hi dear friends

I am going to integrate Revit into structural health monitoring sensors data capturing, storage and visualization. For this purpose, I modeled a building in Revit with several hypothetical sensors such as Accelerometer, Thermocouples, and Strain gauge. Now, I want to make a link between physical sensors and virtual sensors by attaching sensors data (which is usually in the form of text file) to Revit sensors, and then exporting those data, as well as sensors Revit ID, etc into an external database such as MySQL for storage and retrieval purposes as well as some further analysis. Can anybody help and guide me to do this integration. So the two main initial steps are 1: attaching text file sensors data to Revit sensor objects, and 2: mining and sending these attached text file info as well as sensors specification parameters to MySQL database.  
Any help is kindly appreciated in advance.

Thank u so much

---

<div class="post-metadata">

**Author:** ![Andrew\_Hannell](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andrew_hannell/32/103315_2.png) [@Andrew\_Hannell](https://forum.dynamobim.com/u/Andrew_Hannell)\
**Post date:** [December 15, 2016, 9:55pm UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/2 "2016-12-15T21:55:30Z")

</div>

It is possible- but someone is not going to create a complete solution for you. Posting the same thing twice does not help.

To get you started- the main thing is to have a unique key in the model and database that you use to join the records.  
Please post your progress so far.

Andrew

---

<div class="post-metadata">

**Author:** ![MOJTABA256](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@MOJTABA256](https://forum.dynamobim.com/u/MOJTABA256)\
**Post date:** [December 16, 2016, 1:30pm UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/3 "2016-12-16T13:30:52Z")

</div>

Thank you Andrew for your response.  
For the first step, to attach text file to Revit components (sensors), do I have to use Python script in Dynamo, or there is also another easier way, since I am a beginner in Python. Could u please show me the map? Your help is kindly appreciated. Thanx

---

<div class="post-metadata">

**Author:** ![MOJTABA256](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@MOJTABA256](https://forum.dynamobim.com/u/MOJTABA256)\
**Post date:** [December 22, 2016, 8:38pm UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/4 "2016-12-22T20:38:53Z")

</div>

Hi Andrew

I did some works in Dynamo to extract some data from the rooms and specialty equipments in Revit to create two separate table for them. I got some helps from a video in youtube although it was so fast. When I run it, it didn’t work. I attached four files here. an screenshot from the dynamo and MySQl Workbench showing that no table was created in MySQl Workbench, dynamo file, and Revit file. Could u please check them? Thanx

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/a/fabbf8a5f790ace1383a2653845698928f1c1717.png)  
 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/7/77580d5dbf9d18d1b0dd91f90fbefc6929229eb4.png)  
[2.dyn](https://forum.dynamobim.com/uploads/short-url/g6ToBzM1UoMiu50QbV5qWJRQNBv.dyn) (46.7 KB)  

> **[Just In Time Manufacturing.rvt](https://www.dropbox.com/s/hjikhoqv6ag4azq/Just%20In%20Time%20Manufacturing.rvt?dl=0)**
>
> Shared with Dropbox

---

<div class="post-metadata">

**Author:** ![MOJTABA256](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@MOJTABA256](https://forum.dynamobim.com/u/MOJTABA256)\
**Post date:** [December 22, 2016, 8:41pm UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/5 "2016-12-22T20:41:48Z")

</div>

Sorry the Revit file that I uploaded with my other files were wrong. This the correct model. Thanx

> **[Project1.rvt](https://www.dropbox.com/s/grt82ebng7bkjqq/Project1.rvt?dl=0)**
>
> Shared with Dropbox

---

<div class="post-metadata">

**Author:** ![Andrew\_Hannell](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andrew_hannell/32/103315_2.png) [@Andrew\_Hannell](https://forum.dynamobim.com/u/Andrew_Hannell)\
**Post date:** [December 23, 2016, 9:18am UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/6 "2016-12-23T09:18:46Z")

</div>

It is not clear what you are trying to achieve.

The Dynamo graph is chopped off- but it looks like you are concatenating 3 SQL queries to create a database, create tables, & populate the tables with data from Revit/Dynamo

I would suggest breaking it down into separate steps that you can check (and understand) before trying to do everything in one go using Dynamo.

Using MySQL is also quite complicated and only necessary if you have gazillions of records. It would be much simpler to use SQLite- you just point it at a file rather than worrying about ports, authentication modes etc

The steps I would take are

1. Create a database (Dynamo not needed, use Workbench)
2. Create a test table in this database with just one column, and check you can connect to it with something simple like Excel
3. Check you can connect to it from Dynamo using the same connection string and a simple SELECT FROM query
4. Create one table, say Rooms (Dynamo not needed) and populate it with data from Dynamo INSERT INTO…
5. Do the same for the other table (Specialty Equipment)  
and so on.

This way you will understand how it is working, and be able to determine where it is going wrong.

Andrew

---

<div class="post-metadata">

**Author:** ![MOJTABA256](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@MOJTABA256](https://forum.dynamobim.com/u/MOJTABA256)\
**Post date:** [December 24, 2016, 4:09pm UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/7 "2016-12-24T16:09:21Z")

</div>

Thank you Andrew for your helpful information and guidance. I created a database in MySQL Workbench. Then I created a test Schema with a table with 5 columns.  
I tried to only export Room data from Dynamo to this database, but again it failed. I don’t know why. Maybe my server number is wrong. I am sure that the port, userID and password are ok, since I go to my database in workbench by this username and password.  
Could u please try my dynamo file with your own MySQL database? I attached my modified Dynamo file. I had already attached my Revit file before here.  
About SQLite, which software should we install? For example, for MySQL, I downloaded MySQL Workbench. Could u please show me a very simple example of sending Revit data into SQLite using Dynamo? Thank u so much again

[3.dyn](https://forum.dynamobim.com/uploads/short-url/bMmDDWElpIXLgoNIS8TiIHdNF1z.dyn) (23.5 KB)

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/a/1a3aca0113b076f32bb6851f88538894c42cad41.png)

---

<div class="post-metadata">

**Author:** ![Marcel\_Rijsmus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marcel_rijsmus/32/8539_2.png) [@Marcel\_Rijsmus](https://forum.dynamobim.com/u/Marcel_Rijsmus)\
**Post date:** [December 24, 2016, 6:47pm UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/8 "2016-12-24T18:47:30Z")

</div>

Hi,

I had sucses when writing to a SQL (Azure) if i logged on with -servername- and -servername\password- in the DSN while using Revit. Just the password wasnt working for me. It had to be including the anticipatory severname. MySQL might be another puppy, but this helped me

Marcel

---

<div class="post-metadata">

**Author:** ![Andrew\_Hannell](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andrew_hannell/32/103315_2.png) [@Andrew\_Hannell](https://forum.dynamobim.com/u/Andrew_Hannell)\
**Post date:** [December 26, 2016, 6:57am UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/9 "2016-12-26T06:57:56Z")

</div>

@MOJTABA256

Testing it in my environment would not prove much- I’d have to try and replicate exactly what you have, including the same database, authentication mode, ports etc

This is why I recommend SQLite- you don’t need to worry about any of this, just point it at a file,  
I would recommend [http://sqlitestudio.pl](http://sqlitestudio.pl) or ETLTools Database browser tools for working with the database outside of Dynamo

As I said- you should break it down into smaller steps and then you will be able to to work out where it is failing.  
Did you do my step 3. i.e connecting to the database using something simple ? Such as Excel or the aforementioned tools

You graph is too complicated if you do not understand what it is doing.  
Start off simple, and work up from there.The following demonstrate how to create a database, then verify it is working from Dynamo.

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/9/29add3b55933f4db052f19a21f8f059cbaf8454a.gif)  
 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/e/2ec219dd4bf98b6e39976aa6fc96968707beac61.PNG)  
 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/6/a68e21395291c23070e6ffcf6289edaefd69ea5d.PNG)

---

<div class="post-metadata">

**Author:** ![MOJTABA256](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@MOJTABA256](https://forum.dynamobim.com/u/MOJTABA256)\
**Post date:** [December 28, 2016, 3:23pm UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/10 "2016-12-28T15:23:23Z")

</div>

Thank u so much Andrew for your explanation. Finally I could create an Schema in MySQl Workbench using Dynamo called “Facility Management” as shown in attached pic. But I do not know why my code doesn’t work for creating table. I am going to create a table called “Rooms” with two columns, Room\_ID and Name. But it gets fail, Do you have any idea?

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/1/a1fc095be1bf59fd90d610cdbdcad892aed0e8e7.png)  
 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/2/2292fbac933a244b5618a0bdaac41ec52471e022.png)

---

<div class="post-metadata">

**Author:** ![MOJTABA256](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@MOJTABA256](https://forum.dynamobim.com/u/MOJTABA256)\
**Post date:** [December 28, 2016, 3:27pm UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/11 "2016-12-28T15:27:34Z")

</div>

Thanx Marcel. the password and username and server were solved for me, since I could create a Schema in MySQL workbench using Dynamo. My problem now is that my code for creating a table called “Rooms” with two columns (Room\_ID and Name) as shown in my attached pic does not work. Do you have any idea? Does my code have problem? Thanx

---

<div class="post-metadata">

**Author:** ![Andrew\_Hannell](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andrew_hannell/32/103315_2.png) [@Andrew\_Hannell](https://forum.dynamobim.com/u/Andrew_Hannell)\
**Post date:** [December 28, 2016, 9:46pm UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/12 "2016-12-28T21:46:35Z")

</div>

@MOJTABA256

I would remove all unnecessary stuff from the graph  
i.e isolate just the table creation part so you can determine where it fails

You don’t need the schema creation (it is already done) and the writing attributes part (will not work until the table exists)

And simplify the table creation so that it is just one code block, without the concatenation of database and table names, with just one varchar column

Assuming this works, you can build it back up and test as you go, and you will probably find out where it was failing

Although your database seems to have worked, it is good practice not to use spaces in database, table or column names

Good luck

Andrew

---

<div class="post-metadata">

**Author:** ![MOJTABA256](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@MOJTABA256](https://forum.dynamobim.com/u/MOJTABA256)\
**Post date:** [December 30, 2016, 12:42am UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/13 "2016-12-30T00:42:35Z")

</div>

Dear Andrew. Thanks

As you suggested, I remove all unnecessary nodes for this step. But I don’t know why again it failed. I tried the same code block with different spaces and etc. but it hasn’t worked yet. Could u please show me how to create a table with one column under a defined Schema in MySQL by Dynamo? I think my code block has a very small problem. Thanx

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/4/747f7e794067c12185ce5b5595b0d4d81b950ea8.png)

---

<div class="post-metadata">

**Author:** ![Andrew\_Hannell](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andrew_hannell/32/103315_2.png) [@Andrew\_Hannell](https://forum.dynamobim.com/u/Andrew_Hannell)\
**Post date:** [December 30, 2016, 1:06am UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/14 "2016-12-30T01:06:38Z")

</div>

Can you post your graph (dyn file)

---

<div class="post-metadata">

**Author:** ![Andrew\_Hannell](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andrew_hannell/32/103315_2.png) [@Andrew\_Hannell](https://forum.dynamobim.com/u/Andrew_Hannell)\
**Post date:** [December 30, 2016, 11:52am UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/15 "2016-12-30T11:52:26Z")

</div>

On second thoughts, please just carefully follow what I have suggested in earlier posts  
To create a table, you only need 4 nodes:

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/6/265a490e141aa41b400c5868e0b10dc367bbfa68.gif)

---

<div class="post-metadata">

**Author:** ![MOJTABA256](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@MOJTABA256](https://forum.dynamobim.com/u/MOJTABA256)\
**Post date:** [December 31, 2016, 5:57pm UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/16 "2016-12-31T17:57:06Z")

</div>

Thanx Andrew. For me it finally worked. The problem was using spacing in the name of database (Facility Management). I will go for the next step and let you know if I have any question. Thanx again for all your helps

---

<div class="post-metadata">

**Author:** ![MOJTABA256](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@MOJTABA256](https://forum.dynamobim.com/u/MOJTABA256)\
**Post date:** [January 9, 2017, 4:55pm UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/17 "2017-01-09T16:55:32Z")

</div>

Hi Andrew  
In the next step, I could make a link between the database and the table, which I already created in MySQL, and Revit model. Now I want to update the Revit database if something is added or modified in MySQL. For this purpose as you showed me before, I read Values from SQL Table using Query.MySQL\_Query node. I know that I may have to use Element SetParameterByName node to do that, but I am not sure, because When I did it, it didn’t work for me. Do you have any idea? I attached a picture from it. After I mined the values from the Revit and sent it to MySQL. I modified one of them and tried to update Revit model. But it failed. Do you know how can I solve this issue? Thanx

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/c/8cc262ea83adbfdc2f06fa040b4a8528c8b1933b.png)

---

<div class="post-metadata">

**Author:** ![sefabio](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@sefabio](https://forum.dynamobim.com/u/sefabio)\
**Post date:** [July 6, 2017, 7:04pm UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/18 "2017-07-06T19:04:34Z")

</div>

Hi, i have the same issue, i can créate the tables, rows, but i cant move any data from dynamo to Mysql in that rows, do you have any ideas? thanks a lot!!!

---

<div class="post-metadata">

**Author:** ![Andrew\_Hannell](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andrew_hannell/32/103315_2.png) [@Andrew\_Hannell](https://forum.dynamobim.com/u/Andrew_Hannell)\
**Post date:** [July 9, 2017, 11:30pm UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/19 "2017-07-09T23:30:50Z")

</div>

This is an old thread.  
Please start a new one and post details of your work showing where the problem is

Andrew

---

<div class="post-metadata">

**Author:** ![nasrinn](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@nasrinn](https://forum.dynamobim.com/u/nasrinn)\
**Post date:** [June 26, 2024, 7:07pm UTC](https://forum.dynamobim.com/t/revit-mysql-link/8272/20 "2024-06-26T19:07:02Z")

</div>

Hi Dr. Mojtaba,

I hope you are doing well.

I am trying to connect Dynamo to MySQL Workbench, but so far the connection has not worked. I have successfully connected to MySQL Workbench through Visual Studio Code and was able to read and insert values from VS Code to Workbench.

Could you please kindly share how you resolved the connection issue between Dynamo and MySQL Workbench?

Thank you in advance for your time.

Kind regards,  
Nasrin
