Forum Discussion
Mr_Bro
Champion Level 0
Please find the below python script to retrieve the data from database and log the count the record set.
import sys
sys.path.insert(0,r'c:\users\skuma37\appdata\roaming\python\python38\site-packages')
import mysql.connector
def SampleDBCheck():
connection = mysql.connector.connect(
host="HOSTNAME",
database='DATABASENAME',
user="USERNAME",
password="PASSWORD"
)
sql_select_Query = "select * from SampleTable where id < 10"
cursor = connection.cursor()
cursor.execute(sql_select_Query)
records = cursor.fetchall()
Log.Message("Total number of rows in table: "+ str(cursor.rowcount))
rohini11
3 years agoNew Contributor
Hi Satish,
Thanks for the reply.
I'm beginner in coding and trying to work with Java script.
- Mr_Bro3 years agoChampion Level 0
rohini11 ,
can you please try the below snippet by changing the necessary connecting string and query and tell us what is the error:
function TestProc() { var AConnection, RecSet; AConnection = ADO.CreateADOConnection(); AConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;"+ "Data Source=C:\\Users\\Public\\Documents\\TestComplete 14 Samples\\Desktop\\Checkpoints\\XML\\DataGridViewSample\\OrdersDB.mdb"; AConnection.LoginPrompt = false; AConnection.Open(); // Execute a simple query RecSet = AConnection.Execute_("SELECT * FROM orders WHERE [quant] > 1"); RecSet.MoveFirst(); while(! RecSet.EOF) { //Print the recordset value into the Log Log.Message(RecSet.Fields.Item("name").Value); RecSet.MoveNext(); } AConnection.Close(); }
Related Content
Recent Discussions
- 24 hours agojstaehlin