ATG SQL repository to export and import data

Step 1: Create the below table in mysql, database - atgdb database :
use atgdb;
create table employee
id varchar(10) primary key,
name varchar(50),
city varchar(20),
salary double

Step 2: Insert the below values in the employee table:
insert into employee values('1001','Subodh Kumar','Noida',123.77);
insert into employee values('1002','Sumit Singh','Patna',213.33);
insert into employee values('1003','Pawan Kumar','Delhi',3456.66);
insert into employee values('1004','Jagdev Singh','Mumbai',234.55);
insert into employee values('1005','Munna Singh','Chennai',2222.22);
insert into employee values('1006','Narendra Modi','Kolkata',453.45);
insert into employee values('1007','Akhilesh Yadav','Pune',9865.67);

Step 3: Create ATG project based on TestDynamusic project :

You will be get below screen -

Step 4: Create SQL Repository :
Open ATG Component view -> right click on TestDynamusic -> atg -> New Repository ->

Specify the ATG Component name as ContentRepositories below -

Step 5: Edit the below entry in - TestDynamusicconfigtg -

Step 6: Create SQLRepository for employee table -
# /dynamusic/EmployeeRepository
#Mon Jan 05 21:23:11 IST 2017

Step 7: Create Employee Repository mapping file - TestDynamusicconfigdynamusicEmployeeRepository.xml -


emp" default="true">
employee" type="primary" id-column-names="id">
id" data-type="string" />
name" data-type="string" />
string" />
salary" data-type="string" />

Step 8: Use below command to export data from database -
C:ATGATG10.2home>binstartSQLRepository -m TestDynamusic -export all emp-data.xml -repository /dynamusic/EmployeeRepository

Note : run this command from C:ATGATG10.2home and open C:ATGATG10.2homeemp-data.xml and analyze it.

Step 9: Import all the data from SQL Repository file into the Employee table Delete all the records from employee table and run the below command -
binstartSQLRepository -m TestDynamusic -import emp-data.xml /dynamusic/EmployeeRepository.xml

Step 10: Show all the remords from Employee table -


Share your valuable comment

Name :
Email Id : [ We will not publish your email id ]
Your Comment : [ Maximum 200 chars ]
Enter Security code :