18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
execute sql script on database
Hi,
Is it possible to launch a database script in sahi? I've seen the functions to execute an update or select on a db, but after my test is finished, I would like to reset my database to the initial status by performing a delete and load.
Thank you in advance.
Best regards,
Werner
Is it possible to launch a database script in sahi? I've seen the functions to execute an update or select on a db, but after my test is finished, I would like to reset my database to the initial status by performing a delete and load.
Thank you in advance.
Best regards,
Werner
Comments
You can use delete instead of update to delete or reset the database.
For more details you can follow the below link:
http://sahi.co.in/w/_getDB
Let me know if this solves your issue.
Regards
Sumitra
Actually I need to execute several sql statements to restore my database to the start sitatuation.
Statements like:
- create procedure...
- drop trigger...
- truncate table...
- load from <file> insert into <table>
All these statements are grouped in a sql file and I would like to launch/execute these statements on the db within sahi.
You can do this:
$contents = _readFile("queries.sql");
rs = _getDB();// connect to ur database
rs.update($contents);
For more details to connect to db:
http://sahi.co.in/w/_getDB
Let me know if this solves your issue.
Regards
Sumitra
It's not possible to execute the sql statements in the file this way. But I noticed that it's possible to start a stored procedure (routine) on the database with db.update(). So this solves my problem.
I have one last question: in case there goes something wrong, an exception message is send to the console (example: java.sql.SQLException: Routine (restore_dbtest) can not be resolved.) Can I catch this messsage in the code? The command var $string = db.update("Execute procedure restore_dbtest();"); returns null.