An open API service indexing awesome lists of open source software.

https://github.com/nomemory/pysert

A python script that can be used to generate arbitrarily data. Initially written the script around 2012, found it in the google code archives.
https://github.com/nomemory/pysert

Last synced: over 1 year ago
JSON representation

A python script that can be used to generate arbitrarily data. Initially written the script around 2012, found it in the google code archives.

Awesome Lists containing this project

README

          

# pysert

A python script that can be used to generate arbitrary formatted data.

For a more complex solution, please check www.mockneat.com - a Java library that does exactly what this script does, and much more.

_(Note: Script I've written in 2012, found it in the google code archives)._

# Using the script

To be used with `python3`:

```python
python3 pysert.py -i tmpl.xml -o out.txt
```

`tmpl.xml` is the template based on which the script will generate the data:

```xml









INSERT INTO EMPLOYEES
(EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL, JOB_ID, SALARY)
VALUES
(#{id}, '#{fname}', '#{lname}', '#{fname}_#{lname}@domain.com', #{jobid},
#{salary})


```

After running the above command, a fille called `out.txt` will be generated.
The contents of the file are actual SQL Inserts:

```SQL
INSERT INTO EMPLOYEES
(EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL, JOB_ID, SALARY)
VALUES
(300, 'Paula', 'Chehachkov', 'Paula_Chehachkov@domain.com', 175,
8439)

INSERT INTO EMPLOYEES
(EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL, JOB_ID, SALARY)
VALUES
(301, 'Gabriel', 'Vlas', 'Gabriel_Vlas@domain.com', 183,
11362)

INSERT INTO EMPLOYEES
(EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL, JOB_ID, SALARY)
VALUES
(302, 'Mia', 'Fugger', 'Mia_Fugger@domain.com', 181,
2080)

// (... and so on)
```

# Supported datasets

The supported datasets you can use are:

* `RandomNumber`:
- `"name"`: ``
- `"floating"` : `""`
- `"min"`: `""`
- `"max"`: `""`
* `LoremIpsum`:
- `"name"` : ``
- `"length"` : `""`
* `PersonalName`:
- `"name"` : ``
- `"firstname"` : `""`
- `"lastname"` : `""`
* `Sequence` :
- `"name"` : ``
- `"start"` : `""`
- `"increment"` : `""`

# Adding your own data set:

All you have to do is to:
1. Extend the class `AbstractDataSet`
2. Override the method `def validation_list(self):` by including the properties of the DataSet - script will validate the input `xml` based on that.
3. Overtide the method `def next_value(self):`. Here you define the "arbitrary" / "random" behavior of the data set.