MS SQL database querying. How?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2018
07:49 AM
03-15-2018
07:49 AM
MS SQL database querying. How?
Hi,
I am new to TC and have serious problem with getting data from the database. We use SQL Server and develop our tests in Python, so I would be looking for a Python solution if possible. What I exactly need is simple getting simple select result like in:
sqlQuery = "select * from company where name= '" + companyName + "'"
The goal i to create a simple data access class, that will have a few methods, that take such query as argument and return result (handling opening and closing the connection in the process)
So far I have come up with something like that, but this works only for select count(*) from... query:
class DbHelper: def __init__(self): self.serv = Project.Variables.dbServer def selectCountResult(self, sqlQuery): query = ADO.CreateADOQuery() query.ConnectionString = "DRIVER={SQL SERVER};SERVER=%s;DATABASE=4TransMDF;" % (self.serv) query.SQL = sqlQuery query.Open() result = query.RecordCount query.Close() return result #end class
0 REPLIES 0
