cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting to Sql server db using pyodbc with testcomplete

SOLVED
Highlighted
Occasional Contributor

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

2 ACCEPTED SOLUTIONS

Accepted Solutions
Community Hero

Re: Connecting to Sql server db using pyodbc with testcomplete

Hi,

 

May I wonder if you *really* need this library? What for? Wouldn't built-in ADO object work for you (https://support.smartbear.com/viewarticle/9013/ 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.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================

View solution in original post

Community Hero

Re: Connecting to Sql server db using pyodbc with testcomplete

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 https://community.smartbear.com/t5/TestComplete-Mobile-Application/How-do-i-add-Python-Libraries-and... 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.

 

 

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================

View solution in original post

8 REPLIES 8
Community Hero

Re: Connecting to Sql server db using pyodbc with testcomplete

Occasional Contributor

Re: Connecting to Sql server db using pyodbc with testcomplete

Hi @Marsha_R!
I have tried the solutions mentioned in the trail link but it is still mot working for me!

Do we have any other workaround for this?
Community Hero

Re: Connecting to Sql server db using pyodbc with testcomplete

Hi,

 

May I wonder if you *really* need this library? What for? Wouldn't built-in ADO object work for you (https://support.smartbear.com/viewarticle/9013/ 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.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================

View solution in original post

Community Manager

Re: Connecting to Sql server db using pyodbc with testcomplete

Thanks for sharing your ideas, Marsha, Robert!

 

@mwalia, did you resolve the issue? 

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
Occasional Contributor

Re: Connecting to Sql server db using pyodbc with testcomplete

Hi @TanyaGorbunova

 

Yes ADO object usage can definately be a solutionfor the same.

 

However, I was curious if we can use the external python library pyodbc with Test Complete.

 

Occasional Contributor

Re: Connecting to Sql server db using pyodbc with testcomplete

Thanks @AlexKaras

 

 

 

Thanks for sharing the solution. ADO object works.

 

However, I was curious if we can use the external python library pyodbc with Test Complete.

Community Hero

Re: Connecting to Sql server db using pyodbc with testcomplete

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 https://community.smartbear.com/t5/TestComplete-Mobile-Application/How-do-i-add-Python-Libraries-and... 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.

 

 

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================

View solution in original post

Contributor

Re: Connecting to Sql server db using pyodbc with testcomplete

Hi I'm late to this thread, but I've also been trying to use pyodbc because ADO only works if I'm using a trusted connection - if I try using anything else I get a COM exception (who doesn't love COM?) stating that some unspecified provider wasn't found. I've tried the steps in the links about getting Python modules to work, but had no luck. Unfortunately, as is so often the case, there's no actual documentation that I can find either for using Python modules (the linked instructions actually state that the instructions TestComplete documentation gives is not correct) or for using TestCompletes ADO COM component. I'd prefer to use pyodbc, if for no other reason than it's not COM which I thought had died over 10 years ago. But also because there's available documentation for it and, well, I'm supposed to be writing Python code. It's difficult enough writing code for TestComplete because any reference to TestComplete shows up as an error in the code.
New Here?
Join us and watch the welcome video:
Watch the new Interview