How to send data from Revit to SQLite database

Dear friends

I am trying to send data from my Revit model to SQLite tables. I could make a graph in dynamo to send data from SQLite database to update my Revit model, thanks from dear @Andrew_Hannell, but I couldn’t write a correct script till know. As shown in the picture I am going to send some parameters from my Revit model such as Element ID, Level, Type, Replacement Year and Replacement Cost to some pre-defined columns in a table namely DR_Schedule in SQLite Studio. I also attached my dynamo file here. If you open my file you can check my whole script. Any help and guidance are kindly appreciated. Thank u in advance

Revit to SQLite.dyn (3.0 KB)

What version of Dynamo are you in?

Hi @JacobSmall
How are you?
I am working with version 1.3 :slightly_smiling_face:

Do you have any solution dear @JacobSmall?


I don’t have the SQL database to test with so I can’t be too much help here, but it looks like you want to use a string node instead of a code block. Your formatting is throwing an error as a result of an quote.

Also, and take this with a grain of sand as Im not an SQL guy, that’s node indicates it’s for querying which usually means ‘get data from sql’ rather than ‘send data to sql’.

As Jacob suggested- you need to use the SQLite_Command node (not query)

Your code block node is red because the syntax to build the SQL query string is not correct.
You need to concatenate everything to form the SQL

Fields whose data may contain spaces need to be enclosed in a ’ character, and need to be enclosed in " for Dynamo to treat it literally- so yours would be something like:

"insert into DR_Schedule (RoomElementId,RoomLevel) values (" + RoomElementId + "'" + RoomLevel + "'" +")";

so the output from this node would be:
insert into DR_Schedule (RoomElementId,RoomLevel) values (12345,'01 Entry Level')

I’d recommend not using spaces in the fields (column names) in your database- it just makes it more complicated. Start with just one field and build it up from there.


Many many thanks @Andrew_Hannell

I’ll try it and let you know.

Hi Andrew, i know this topic is old, but how can you manage to operate with string and int64 from elemenId? I expected an error about operand types. thanks in advance.

Hi Sergio,

I don’t recall any problems with datatypes- I could be wrong- but I think I’d have used a text datatype in a SQLite database for elementID.
I’ve been leaning towards Postgres/PostGIS recently for the spatial capabilities
If you have a specific problem- then post relevant files and I’ll take a look


I just saw your other post on this forum- if you post the Dynamo graph, I’ll take a look
You might need to use a CAST in the query


edit: This was meant as a general reply, not specifically “at” @Andrew_Hannell

I use int for element Id values when going to SQL. I think It makes it easier to use coming back in if you need bidirectional communication from you DB.

I should have read it more carefully…

yes, Element.Id is an integer, whereas Element.UniqueId is a string

I tend to use UniqueId as Id can change- say if an element is moved with the disjoin option


Absolutely agree and I do the same!

1 Like

100%. GUID is better than ID for Revit > external data > Revit every time, be it SQL or excel.