Key points of the XMLtoDDL project: synchronize with the database

Source: Internet
Author: User
Tags xml example
For the xml2ddl project, Freshmeat.org provides a complete set of Python programs based on the GNU or GPL general public permit. In a running Python environment, this tool can work on many control systems, including Windows, Linux, and UNIX platforms,

For the xml2ddl project, Freshmeat.org provides a complete set of Python programs based on the GNU or GPL general public permit. In a running Python environment, this tool can work on many control systems, including Windows, Linux, and UNIX platforms. It can also work on the following database engines: PostgreSQL, MySQL, oracle and Firebird.

Then, the xml2ddl running user converts an XML database into a set of SQL or DDL reports. According to Scott Kirkwood, his producer and manager, "XML-to-DDL strives to make the database independent so that the same XML can be used in different databases. For example, it is very useful to quickly test the performance of various databases"

Before starting this process, the xml2ddl running user points to a mode, develops a target database, and presents the necessary DDL or SQL statements to instantiate the database. This simple XML Example is defined as a file named schemal. xml:

Desc = "List of students with their full names">
 
  Desc = "Primary key for the table"/>
  Type = "varchar" size = "80"
Desc = "The full name of the student"/>
 
 

Execute the following command line syntax to call and output the PostgresSQL information: xml2ddl-database schemal. xml. the output is as follows:

Drop table students;
Create table students (
Id integer,
Student_name varchar (80 ),
CONSTRAINT pk_students primary key (id ));
Comment on table students IS 'List of students with their full names ';
Comment on column students. id IS 'primary key for the table ';
Comment on column students. student_name IS 'the full name of The student ';

Instead of firebird, oracle or mysql can generate the same type of output results for other target databases.

The xml2ddl program can also check the differences between two different versions of XML legends and the DDL or SQL statements required by nature to update these identical changes to the relevant target database. This requires two coherent legends (let us call it the second schema2.xml and replace schemal. xml), and apply the syntax shown below:

Suppose that schema2.xml looks as follows:


Desc = "List of students">
 
Desc = "Primary key for the table"/>
Type = "varchar" size = "100"
Desc = "The full name of the student"/>
Type = "varchar" size = "100"
Desc = "The primary email for the student"/>


PostgresSQL generates the following DDL output:

Alter table students ALTER student_name TYPE varchar (80 );
Alter table students DROP email;
Comment on table students IS 'List of students with their full names ';

A complete example can be found on the project website of the project. They make it easy to define and govern databases using XML and related structured compilation tools, and it takes less time to translate your structured XML into a proper database metalanguage, these make these tools very useful.

The value of this is worth thinking about, and it is an amazing data integration and governance tool for those who are honored to become an application of a target database they support.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.