# How to Connect MSSQL DataBase using Robotframework

**URL:** <https://forum.robotframework.org/t/how-to-connect-mssql-database-using-robotframework/5213>\
**Category:** DatabaseLibrary\
**Created:** [27 January 2023 08:34 UTC](https://forum.robotframework.org/t/how-to-connect-mssql-database-using-robotframework/5213 "2023-01-27T08:34:48Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bhaskar](https://avatars.discourse-cdn.com/v4/letter/b/f4b2a3/32.png) [@Bhaskar](https://forum.robotframework.org/u/Bhaskar)\
**Post date:** [27 January 2023 08:34 UTC](https://forum.robotframework.org/t/how-to-connect-mssql-database-using-robotframework/5213/1 "2023-01-27T08:34:48Z")

</div>

I was not able to connect DB , getting error like :- OperationalError: (com\_error(-2147352567, ‘Exception occurred.’, (0, ‘Microsoft OLE DB Provider for ODBC Drivers’, ‘[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified’, None, 0, -2147467259), None), ‘Error opening connection to “localhost”’). can you please help me with this.

---

<div class="post-metadata">

**Author:** ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)\
**Post date:** [27 January 2023 10:30 UTC](https://forum.robotframework.org/t/how-to-connect-mssql-database-using-robotframework/5213/2 "2023-01-27T10:30:01Z")

</div>

You can’t just show an error message and expect us to help based on that. At least you need to show what were the steps you took, and what objective you have.

---

<div class="post-metadata">

**Author:** ![Bhaskar](https://avatars.discourse-cdn.com/v4/letter/b/f4b2a3/32.png) [@Bhaskar](https://forum.robotframework.org/u/Bhaskar)\
**Post date:** [27 January 2023 10:50 UTC](https://forum.robotframework.org/t/how-to-connect-mssql-database-using-robotframework/5213/3 "2023-01-27T10:50:30Z")

</div>

Sure, I was using Library RPA.DataBase in Robot framework and please find the snap .

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/9/9018cb13fa07a3073aa346d218c32a1a267318b4.png)

---

<div class="post-metadata">

**Author:** ![Bhaskar](https://avatars.discourse-cdn.com/v4/letter/b/f4b2a3/32.png) [@Bhaskar](https://forum.robotframework.org/u/Bhaskar)\
**Post date:** [27 January 2023 10:55 UTC](https://forum.robotframework.org/t/how-to-connect-mssql-database-using-robotframework/5213/4 "2023-01-27T10:55:36Z")

</div>

as I mentioned above snap, I was passing arguments based on syntax. but still am facing issue be like No module named ‘psycopg2’

---

<div class="post-metadata">

**Author:** ![Bhaskar](https://avatars.discourse-cdn.com/v4/letter/b/f4b2a3/32.png) [@Bhaskar](https://forum.robotframework.org/u/Bhaskar)\
**Post date:** [27 January 2023 10:58 UTC](https://forum.robotframework.org/t/how-to-connect-mssql-database-using-robotframework/5213/5 "2023-01-27T10:58:08Z")

</div>

here am using PostgresSQL DataBase

---

<div class="post-metadata">

**Author:** ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)\
**Post date:** [27 January 2023 11:03 UTC](https://forum.robotframework.org/t/how-to-connect-mssql-database-using-robotframework/5213/6 "2023-01-27T11:03:12Z")

</div>

This is so confusing. Your initial problem was with MSSQ, and now is with PostgresSQL.

Did you installed the `driver`? Check DatabaseLibrary documentation.

---

<div class="post-metadata">

**Author:** ![Bhaskar](https://avatars.discourse-cdn.com/v4/letter/b/f4b2a3/32.png) [@Bhaskar](https://forum.robotframework.org/u/Bhaskar)\
**Post date:** [27 January 2023 11:07 UTC](https://forum.robotframework.org/t/how-to-connect-mssql-database-using-robotframework/5213/7 "2023-01-27T11:07:17Z")

</div>

I have tried with both databases like MSSQL and Postgres. same problem I was facing

---

<div class="post-metadata">

**Author:** ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)\
**Post date:** [27 January 2023 11:23 UTC](https://forum.robotframework.org/t/how-to-connect-mssql-database-using-robotframework/5213/8 "2023-01-27T11:23:53Z")

</div>

> [@HelioGuilherme66](#):
>
> Did you installed the `driver`? Check DatabaseLibrary documentation.

Because of this, you will have the problem with any database.

---

<div class="post-metadata">

**Author:** ![Bhaskar](https://avatars.discourse-cdn.com/v4/letter/b/f4b2a3/32.png) [@Bhaskar](https://forum.robotframework.org/u/Bhaskar)\
**Post date:** [27 January 2023 11:30 UTC](https://forum.robotframework.org/t/how-to-connect-mssql-database-using-robotframework/5213/9 "2023-01-27T11:30:48Z")

</div>

Yes, I have Installed for Postgres psycopg2==2.9.5 and for MSSQL pymssql==2.2.7

---

<div class="post-metadata">

**Author:** ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)\
**Post date:** [27 January 2023 11:36 UTC](https://forum.robotframework.org/t/how-to-connect-mssql-database-using-robotframework/5213/10 "2023-01-27T11:36:23Z")

</div>

Try to Connect with Custom Connection (name may not be like this).  
Activate the TRACE log level.

Are you using the correct Python version?  
(I almost could bet you are on 3.11 😉 )

---

<div class="post-metadata">

**Author:** ![Bhaskar](https://avatars.discourse-cdn.com/v4/letter/b/f4b2a3/32.png) [@Bhaskar](https://forum.robotframework.org/u/Bhaskar)\
**Post date:** [27 January 2023 11:52 UTC](https://forum.robotframework.org/t/how-to-connect-mssql-database-using-robotframework/5213/11 "2023-01-27T11:52:04Z")

</div>

using Python 3.10.4 version

---

<div class="post-metadata">

**Author:** ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)\
**Post date:** [27 January 2023 12:09 UTC](https://forum.robotframework.org/t/how-to-connect-mssql-database-using-robotframework/5213/12 "2023-01-27T12:09:06Z")

</div>

To troubleshoot the problem.

- Connect to database using command line tools, like `psql` or `pgadmin`
- After confirmation of success, make test case to open connection to DB
- If normal connection keyword did not worked, try the “custom” variant
- Set loglevel to TRACE or at least DEBUG
- Did a restart of the computer helped?
- Try to see logs of the `driver`

When asking for help, try to give minimal info about your system, and preferable use text (code formatted) instead of images. If the code is something we can try, then it would be perfect

---

<div class="post-metadata">

**Author:** ![Bhaskar](https://avatars.discourse-cdn.com/v4/letter/b/f4b2a3/32.png) [@Bhaskar](https://forum.robotframework.org/u/Bhaskar)\
**Post date:** [27 January 2023 12:40 UTC](https://forum.robotframework.org/t/how-to-connect-mssql-database-using-robotframework/5213/13 "2023-01-27T12:40:50Z")

</div>

Sure, Thanks

---

<div class="post-metadata">

**Author:** ![Bhaskar](https://avatars.discourse-cdn.com/v4/letter/b/f4b2a3/32.png) [@Bhaskar](https://forum.robotframework.org/u/Bhaskar)\
**Post date:** [31 January 2023 06:57 UTC](https://forum.robotframework.org/t/how-to-connect-mssql-database-using-robotframework/5213/14 "2023-01-31T06:57:47Z")

</div>

Can you please guide me which drivers, need to install for PostgreSQL connect with Robot framework?

---

<div class="post-metadata">

**Author:** ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)\
**Post date:** [31 January 2023 11:55 UTC](https://forum.robotframework.org/t/how-to-connect-mssql-database-using-robotframework/5213/15 "2023-01-31T11:55:20Z")

</div>

Check the documentation [here](https://franz-see.github.io/Robotframework-Database-Library/api/0.5/DatabaseLibrary.html).

In the link for _Lists of DB API 2.0_ you have the drivers.

Another resource: [Database Library | ROBOT FRAMEWORK](https://docs.robotframework.org/docs/different_libraries/database)
