How to Connect MSSQL DataBase using Robotframework

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.

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.

1 Like

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

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

here am using PostgresSQL DataBase

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

Did you installed the driver? Check DatabaseLibrary documentation.

1 Like

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

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

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

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 :wink: )

using Python 3.10.4 version

1 Like

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

1 Like

Sure, Thanks

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

Check the documentation here.

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

Another resource: Database Library | ROBOT FRAMEWORK