Data generators for SQL server? [closed]

谁说胖子不能爱 提交于 2019-11-27 10:44:31

I've rolled my own data generator that generates random data conforming to regular expressions. It turned into a learning project (under development) and is available at github.

Galwegian

I have used the data generator in the past. May be worth a look.

3rd party edit

If you do not register you can only generate 100 rows. Below you can find a sample how the interface looks today (october 2016)

Pascal Paradis

Something similar has been asked here : Creating test data in a database

Red Gate SQL Data Generator does a great job in that domain. You can customize every field of your database and using random data with seeds. And even create specific patterns using Regex expressions.

For generating sample data, I use simple Python applications.

Considerations:

  1. Simple to modify and configure.

  2. A repeatable set of data that you can for performance testing and get consistent results.

  3. Follow all of the DB referential integrity rules and constraints.

  4. Realistic data.

The first two indicate that you want to produce script files that will load your data. The third is tougher. There are ways to discover the database metadata and constraints. Looking at 3 and 4 together, you don't want simple reverse engineering -- you want something you can control to produce realistic values.

Generally, you want to build an entity model of your own so that you can be sure you have ranges and key relationships correct.

You can do this three ways.

  1. Generate CSV files of data which you can load manually. Nice repeatable test data.

  2. Generate SQL scripts which you can run. Nice repeatable data, also.

  3. Use an ODBC connection to generate data directly into the database. I actually don't like this as much, but you might.

Here's a stripped-down one-table-only version of a data generator that writes a CSV file.

import csv
import random

class SomeEntity( list ):
    titles = ( 'attr1', 'attr2' ) # ... for all columns
    def __init__( self ):
        self.append( random.randrange( 1, 10 ) )
        self.append( random.randrange( 100, 1000 ) )
        # ... for all columns

myData = [ SomeEntity() for i in range(10000) ]
aFile= open( 'tmp.csv', 'wb' )
dest= csv.writer( aFile )
dest.writerow( SomeEntity.titles )   
dest.writerows( myData )
aFile.close()

For multiple entities, you have to work out the cardinality. Instead of generating random keys, you want to make a random selection from the other entities. So you might have ChildEntity picking a random element from ParentEntity to assure that the FK-PK relationship was correct.

Use random.choice(someList) and random.shuffle(someList) to assure referential integrity.

Visual Studio Team System Database Edition (aka Data Dude) does this.

I have not used it for data generation yet, but 2 features sound nice:

  1. Set your own seed value for the random data generator. This allows you to prodcue the same random data more than once.

  2. Point the wizard at a 'real' database and have it generate something that looks like real data.

Maybe these are standard features elsewhere?

Loki

I just found about that one: Spawner

this one is for free: http://www.sqldog.com contains several functions like: data generator, fulltext search, create database documentation, active database connections

Patrick Cuff

I've used a tool called Datatect for this.

Some of the things I like about this tool:

  1. Uses ODBC so you can generate data into any ODBC data source. I've used this for Oracle, SQL and MS Access databases, flat files, and Excel spreadsheets.
  2. Extensible via VBScript. You can write hooks at various parts of the data generation workflow to extend the abilities of the tool.
  3. Referentially aware. When populating foreign key columns, pulls valid keys from parent table.

I have used this before

http://sqlmanager.net/en/products/mssql/datagenerator

Its not free though.

Ref integrity checking is quite important, or your tests will be no good without correlating related data.(in most cases)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!