Forum Discussion

mwalia's avatar
Occasional Contributor
6 years ago

Connecting to Sql server db using pyodbc with testcomplete

Hi All,

I am trying to integrate a python pyodbc extension in TestComplete 12.6 as a trial user for connecting SQL server database.
I have tried the below approaches:
1. Added the ‘pyodbc’ extension installed using python pip on site-packages folder at <TestComplete>\Bin\Extensions\Python\Python36\Lib folder and used the import command."
import pyodbc
<your code here>
Error: No module named pyodbc found

2. Used the below code to do the needful as well:
from os import
sys.path.insert(0, '%PATH_TO_PYTHON_DIRECTORY%\Lib\site-packages')

import pyodbc
Error: No module named pyodbc found

Any help will be appreciated

  • Hi,


    May I wonder if you *really* need this library? What for? Wouldn't built-in ADO object work for you ( and other articles from the SQL section) ?


    P.S. A side benefit of using objects and functionality provided by TestComplete itself is that the resulting code is more portable i when you need to use it for the project based on some other scripting language.


  • Hi,


    > if we can use the external python library pyodbc with Test Complete.

    I would say that this should be possible. The link posted by Marsha_R and the whole thread with replies from baxatob are worth reading and carefull follow-up. I am not a Python expert but it is my understanding that Python, like Java/Groovy, is pretty sensitive to correct paths and module versions but not always provides a clear and descriptive problem diagnostic. Thus, you must be careful, understand what you are doing and have an idea of what paths and default locations Python's engine may examine on your system while searching for this or that module.




8 Replies