# Connect and use an SQL db

**URL:** <https://discourse.nodered.org/t/connect-and-use-an-sql-db/2601>\
**Category:** General\
**Created:** [27 August 2018 13:05 UTC](https://discourse.nodered.org/t/connect-and-use-an-sql-db/2601 "2018-08-27T13:05:41Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andres](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andres/32/112_2.png) [@Andres](https://discourse.nodered.org/u/Andres)\
**Post date:** [27 August 2018 13:05 UTC](https://discourse.nodered.org/t/connect-and-use-an-sql-db/2601/1 "2018-08-27T13:05:41Z")

</div>

Hi everyone, so i'm new to SQL databases, but i'm trying to learn. I've an db implemented but i can't connect with it, i'm using the "node-red-contrib-sql" and when i configure the server it should (for what i believe) automatically retrieve all tables availables (i've some), but it doesn't retrieve anything (the db works fine). Can someone helpme? What info do you need?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [27 August 2018 13:45 UTC](https://discourse.nodered.org/t/connect-and-use-an-sql-db/2601/2 "2018-08-27T13:45:49Z")

</div>

step 1: can you connect to the database and add retrieve data without using node-red?

step 2: what do the node-red logs say?

---

<div class="post-metadata">

**Author:** ![Andres](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andres/32/112_2.png) [@Andres](https://discourse.nodered.org/u/Andres)\
**Post date:** [27 August 2018 14:22 UTC](https://discourse.nodered.org/t/connect-and-use-an-sql-db/2601/3 "2018-08-27T14:22:02Z")

</div>

i can connect to the database and retrieve data without node-red.

it appears a red triangle over the node (the one that means that something is not configured), if i ignore that and inject something on the node this is thrown: "Error: Pool was destroyed"

---

<div class="post-metadata">

**Author:** ![tree-frog](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tree-frog/32/89303_2.png) [@tree-frog](https://discourse.nodered.org/u/tree-frog)\
**Post date:** [27 August 2018 15:35 UTC](https://discourse.nodered.org/t/connect-and-use-an-sql-db/2601/4 "2018-08-27T15:35:46Z")

</div>

Andres,  
I had some initial errors as well. The information does not tell you that if you connect using SQL permission you need to blank the domain. You cannot use both domain and SQL sign on. If you sign on as Windows permission, you may need the password as part of your login however. Hope this helps.

---

<div class="post-metadata">

**Author:** ![Andres](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andres/32/112_2.png) [@Andres](https://discourse.nodered.org/u/Andres)\
**Post date:** [28 August 2018 12:39 UTC](https://discourse.nodered.org/t/connect-and-use-an-sql-db/2601/5 "2018-08-28T12:39:05Z")

</div>

Sorry, i didn't understand your answer. In the part where you can edit the info of the server you have the following fields (and what do i believe what i have to put):

- **_Name_** : this field doesn't matter to the server
- **_Dialect_** : for a sql database i believe that i have to select the PostgreSql
- **_Host | Port_** : ip of the sql server | port of the sql server
- **_Database_** : name of the database
- **_Username_** : username of the sql server
- **_Password_** : password of the sql server
- **_Minimum number of connections_** : i have no idea what this is for (i just put 0)
- **_Maximum number of connections_** : also i have no idea what this is for (i just put 2)
- **_Use SSL_** : i believe that this is for secure conections

Note, the SQL server and the node-red are not working on the same pc.

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [28 August 2018 12:51 UTC](https://discourse.nodered.org/t/connect-and-use-an-sql-db/2601/6 "2018-08-28T12:51:30Z")

</div>

> [@Andres](#):
>
> _ **Dialect** _ : for a sql database i believe that i have to select the PostgreSql

I don't believe you have told us which database you are using. It would be much easier to help if you posted a flow and details of your database.  
Garry

---

<div class="post-metadata">

**Author:** ![Andres](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andres/32/112_2.png) [@Andres](https://discourse.nodered.org/u/Andres)\
**Post date:** [28 August 2018 13:31 UTC](https://discourse.nodered.org/t/connect-and-use-an-sql-db/2601/7 "2018-08-28T13:31:59Z")

</div>

i'm using a **_microsoft sql_** database, the administrator of it told me that is none of those dialects (refearing to the 3 that the config. node provides). About the flow, i don't have one, since i can't connect to the db.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [28 August 2018 13:40 UTC](https://discourse.nodered.org/t/connect-and-use-an-sql-db/2601/8 "2018-08-28T13:40:57Z")

</div>

maybe you need a node more suited to MSSQL?... there are several on [flows.nodered.org](http://flows.nodered.org)

[https://flows.nodered.org/?term=mssql&num\_pages=1](https://flows.nodered.org/?term=mssql&num_pages=1)

---

<div class="post-metadata">

**Author:** ![Andres](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andres/32/112_2.png) [@Andres](https://discourse.nodered.org/u/Andres)\
**Post date:** [28 August 2018 13:46 UTC](https://discourse.nodered.org/t/connect-and-use-an-sql-db/2601/9 "2018-08-28T13:46:37Z")

</div>

Ok, i'll try that option, i will post any update. Thanks!

---

<div class="post-metadata">

**Author:** ![arneym](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/arneym/32/54_2.png) [@arneym](https://discourse.nodered.org/u/arneym)\
**Post date:** [28 August 2018 15:17 UTC](https://discourse.nodered.org/t/connect-and-use-an-sql-db/2601/10 "2018-08-28T15:17:05Z")

</div>

I am currently using node-red-contrib-mssql for my microsoft sql database transactions. If you are not committed to using node-red-contrib-sql, then give the node above a try.

This is a very easy setup  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e5382e9c8c350801e9c1b18dcfd98ac36dcf34d8.png)

Thanks,  
Mike

---

<div class="post-metadata">

**Author:** ![tree-frog](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tree-frog/32/89303_2.png) [@tree-frog](https://discourse.nodered.org/u/tree-frog)\
**Post date:** [29 August 2018 12:56 UTC](https://discourse.nodered.org/t/connect-and-use-an-sql-db/2601/11 "2018-08-29T12:56:13Z")

</div>

Andres,  
I was under the impression you were using the "MSSQL" node vs the default "sqldbs". Perhaps I missed which node you were using.

You need to install it from your "Manage Palette" and "Install" tab. Install "node-red-contrib-mssql-plus".

The MSSQL will attach to any Microsoft SQL database. I connect to 2008R2 and SQL Server 2000 servers on our domain. Again, if you log into the SQL with SQL Server permission, you do not use the domain. That was my point. I hope that clears up the mud.

---

<div class="post-metadata">

**Author:** ![Andres](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andres/32/112_2.png) [@Andres](https://discourse.nodered.org/u/Andres)\
**Post date:** [29 August 2018 13:16 UTC](https://discourse.nodered.org/t/connect-and-use-an-sql-db/2601/12 "2018-08-29T13:16:08Z")

</div>

@dceejay that was what i needed.

I'm currently using MSSQL-PLUS.

@arneym Thanks for that screenshot, it was what i needed for configuring the node in the right way!

Thanks to all for your answers!
