Forum Discussion

pradeep_kamatha's avatar
pradeep_kamatha
Contributor
11 years ago
Solved

Can anyone help me how to access Mongo database?

Does any knows how to access Mongo database? Currently we new database to test our application which doesn't give like Provider=OraOLEDB.Oracle.1 similar like Oracle.  I do access Oracle  with the following connection string.

Provider=OraOLEDB.Oracle.1;Password=ami_admin;Persist Security Info=True;User ID=ami_admin;Data Source=DFLY-ST.MDMR01



Similar way I need it for Mongo database.



Thanks

Pradeep kamatham

10 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Pradeep,


     


    There should be a special ODBC driver for MongoDB that you need to install. I found the following ones:



     - https://github.com/NYUITP/sp13_10g - it's a free driver, but, as far as I understand, it's in a beta state.


    Refer to the driver documentation to learn the connection string you need to use.


     


    There is another approach: data from MongoDB can be exported to the CSV format. Once you do this, it will be possible to work with CSV files in TestComplete via the Data-Driven Testing feature.


     

  • Hi there, a little now for you I fear, but just in case anyone has any similar issues connecting to MongoDB, this is to let you know that Easysoft have just launched their MongoDB ODBC Driver for Windows.
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Pradeep,



    Assuming that you already created an ODBC DSN to your database, I would recommend the following:

    a) Right-click on the desktop and create a new text document;

    b) Change extension of the created .txt file to .udl;

    c) Double-click this .udl file. This will open the standard ADO data link properties window;

    d) In this window, switch to the Provider tab and select the OLE DB Provider for ODBC Drivers. Press Next button;

    e) In the ensuing Connection tab select the Use data source name option button and select DSN to the database in the combo-box;

    f) Fill any other required fields and press the Test Connection button to check that ADO can successfully connect to the database via your DSN connection;

    g) Press OK button to save changes to the .udl file and close the data link properties window;

    h) Open .udl file using any text editor (Notepad is quite OK) and copy the connection string. Use this connection string to connect to the database when using ADO objects in TestComplete.
  • Thanks for your respone. I have downloaded trail version of Simba Mongo db driver and installed in my local machine from where I can access Mongo DB. Can you please suggest me how to configure this ADO dirver into Test complete.
  • Hi Tanya,



    Once I get connected to Mongo through Simba ODBC driver, what are the paramerter do I need to pass to connect Test complete. I had a chat with Simba support team and they are not quite sure to  access Test complete.  When i setup a driver the below are the objects are displayed from Simba Mongodb ODBC drvier setup



    Data source Name :



    Description :

    Host :

    Port :

    Database :

    User name :



    Please advise what parameters do I have to pass to access TC.
  • Hi Alexei,



      I have managed to go til Test connection, looks it is failed because of "" Test Connection failed because of an error in initializing provider Unspecified error".

    I am able to Connect to Mongo db through Somba Mongo DB ODBC Driver. I have given same Data source , User name and password in connection tab to check the Test connection, some reasons it was failed.  How ever .UDL file has the below connection string printed, I belive which is incorrect.  My Data source name is AmiIntervalData, it has user name and password, seemd only user ID has written in the file.



    [oledb]

    ; Everything after this line is an OLE DB initstring

    Provider=MSDASQL.1;Persist Security Info=False;User ID=root;Data Source=AmiIntervalData

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Pradeep,



    Considering that you can access the database via ODBC DSN but cannot when using OLE DB, the problem is with the OLE DB connection settings.

    I did not use Mongo ODBC driver, so can provide some general comments:

    a) Password is not stored in the .udl file because you have 'Persist Security Info=False;' specified. This can be changed by checking the 'Allow saving password' option on the Connection tab of the Data Link Properties window;

    b) Hovewer, if the user name and password are specified in the ODBC DSN connection, it may be that you should leave User Name and Password fields empty in the Connection tab of the Data Link Properties window. Just try to Test Connection with and without User Name and Password values provided and with the Allow Savibg Password option checked and not.



    Otherwise, your connection string looks quite correct.
  • Hi Alex,



     I am using Mircrosoft OLE DB Provider for ODBC Driver, I am not sure where do i go and change the settings. I tried all the possible ways to test Test condition. I was failed totally to make it run. untill it succeeded I can't get connection string from .udl file.  I can understand you are not worked on Mongo, which is really weired database.  Thanks for you  great help!!
  • Can anyone tell me the other way to access Mongo db data rather using ADO Driver. I know  Mongo will provide free webservice to access data from specific collection(table). I am not sure how would we compare webservices to check the data against database. Please help me out.
  • sagnik80's avatar
    sagnik80
    Senior Member

    Hi Tanya

     

    I have used the connection string to connect to mongodb after installing the necessary driver -

    mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]

     

    But getting error - "Failed to Init conn"

     

    Any pointersa on this will be very helpful. Thanks!

     

    Regards

    Sagnik