Random .Net SQL Generator (Open Source)

A random generator for all types of queries in SQL - extend-able to any SQL provider

I have often ran into the case where I need to insert a bunch of random records against a table or do a lot of queries to test for integrity - but those tools always seem to cost money. Some classmates and I did a project last semester that allowed for random SQL generation of all types. This is a generation tool for random queries in SQL in the Windows environment. It can produce random queries, tables, deletes, and updates as well as generate random data for a table. This was implemented with PostgresSQL, but we tried to structure it to allow easy adaptation for other SQL implementations as well.

The interface was meant to be very simple and requires no information about the tables themselves, just feed in basic information like the connectionstring and the table name to run the query against:

insert 100 random records

PgSqlGenerator pg = new PgSqlGenerator("", 5432, 
    "postgres", "sql", "my_database");
Table people = pg.GetTable("people");
QueryInformation report = 
    pg.ExecuteBulkInsert(people, 100);

//now check the results:
Console.WriteLine("Query: " + report.Query);
Console.WriteLine("Time Taken: " + report.Time);
Console.WriteLine("Rows Affected: " + report.Affected);

It is far from bug-free, but works very well - figured we would share what we did.

Add comment