Page 1 of 1

Data Generator : Add Custom Generator

Posted: Thu 27 Aug 2015 15:20
by smith
Hello,

Can i add custom data generator ?
I want to add a group tree like "Custom" and and I provide the data or I want to add a new data model in
Business tree or IT tree or Product tree or Health tree, etc. So I can adjust the data

Best Regards,
Eric Santoso

Re: Data Generator : Add Custom Generator

Posted: Fri 28 Aug 2015 12:22
by .jp
Hi,

Thanks for the question.

The addition of new categories to the generators tree is not available in this version and will be implemented in a future version.

At this point, you can add your own generator to one of the existing categories: Business, Health, Location, IT, Payment, Personal, or Product.

To add a new generator, please do the following (the example is provided based on the regular expression generator, since it is the most customizable one):

1. Open the folder:
"C:\Users\Public\Documents\Devart\dbForge Data Generator for SQL Server\Data Generators"
and create a file with the extension *.xml or copy/paste one of the existing files, and edit it;

2. The file should contain the code:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<Generators xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Generator>
    <Category>IT</Category>
    <Name>Enter a generator name here</Name>
    <ShortName>Enter a short name here</ShortName>
    <Description>Enter a description here</Description>
    <Type>SqlRegularExpressionGenerator</Type>
    <ColumnTypes>
      <Type>varchar</Type>
      <Type>char</Type>
    </ColumnTypes>
    <Matches>
      <Match table=".*Test.*" сolumn=".*Name.*" Priority="100" minlen="4"/>
      <Match table=".*Test.*" сolumn="Name" priority="90" minlen="4"/>
      <Match table=".*Test.*" сolumn="Name" priority="80" minlen="4"/>
      <Match table=".*" сolumn="^Addr.*Type$" priority="70" minlen="4"/>
      <Match table="Language" column="Lang.*Id$" priority="60" minlen="2"/>
      <Match table=".*" сolumn="^extn.*" priority="20" minlen="50" maxlen="60"/>
      <Match table=".*" сolumn="^SIN$" priority="5"/>
      <Match table="(Person|User|Cust|Emp|Employee)" column="SIN" priority="10"/>
    </Matches>
    <Options>
      <Expression>Your regular expression should be here</Expression>
    </Options>
  </Generator>
</Generators>
3. Explanation of tags:
3.1 <Category>IT</Category> - the category a custom generator is added to;
3.2 <Name>Enter a generator name here</Name> - the name of a generator being added;
3.3 <ShortName>Enter a short name here</ShortName> - the name of a generator that will be displayed in the Preview window;
3.4 <Description>Enter a description here</Description> - the description of a generator;
3.5 <Type>SqlRegularExpressionGenerator</Type> - the type of a basic generator on which a created generator is based;
3.6 <ColumnTypes><Type>varchar</Type><Type>char</Type></ColumnTypes> - data types for which a generator will be available;
3.6.1 Data types: any of SQL Server data types;
3.7 <Matches></Matches> - adds the rules for auto-mapping;
3.7.1 Mapping rules:
table="" - a name of the matched table(s);
column="" - a name of the matched column(s);
. * - any number of characters;
^ - strict beginning of a name, i.e. "^Test.*" means that the beginning of the name must be "Test", followed by any characters (the valid table names are the following: test, testing, Test123, etc);
$ - strict end of a name, i.e. ".*Test$" means that the end of the name must be "Test", preceded by any characters (the valid table names are the following: test, myTest, 123test, etc);
| - "or" listing;
priority="n" - mapping priority - the rule according to which a generator is automatically assigned to a column (the higher the number, the higher the priority; for the custom generators it should be higher than 4 because default sql data type generators have the priority range between 1 and 4);
minlen="n" - the minimum permissible length of a column (the parameter is ignored for varchar(max), text, image and similar sql data types);
maxlen="n" - the maximum length of a column (this parameter is optional; the parameter is ignored for varchar(max), text, image and similar sql data types).
3.8 <Expression>([0-9A-Z])</Expression> - regular expression that will automatically fill a table column with generated data;

4. Save the *.xml file.
5. Launch (or relaunch) the dbForge Data Generator.

Have you managed to add your own data generator?

Best Regards.

Re: Data Generator : Add Custom Generator

Posted: Sat 29 Aug 2015 02:04
by smith
Hello,

thank you, yes, it works

Best Regards