문제

I have "db_dump.sql" file. Which consist of some data for testing. I need to import this into the PG DB before starting the test run.

I checked http://franz-see.github.io/Robotframework-Database-Library/api/0.5/DatabaseLibrary.html, but did not find any keyword to import DB dump.

Do we have an existing keyword to import DB dump?

도움이 되었습니까?

해결책

If what you have is an SQL file, then you don't need a keyword that specifically import a database but you need a keyword that can execute a SQL file (the statements in the file are going to create the schema, tables, FK etc.). In the library you mention you should be able to yse "Execute Sql Script" keyword for that.

다른 팁

This is how I solved the above issue:

Create a file with command to import the Postgres dump.

Create File importdump.sh content=psql -d dbName -h hostName -p 5432 -U username -f ${DUMP_FILE_LOCATION} encoding=ASCII

Run the script

Run sh importdump.sh

Here, ${DUMP_FILE_LOCATION} = /path/to/the/file/db_dump.sql

The keyword 'Execute Sql Script' is useful to run the commands once connected to the DB. In this scenario, the dump file was on my local machine and the PG is an ec2 instance.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top