# Welcome

&#x20;

<figure><img src="/files/i0f7mvPM77AJ8WmNY78M" alt="" width="198"><figcaption><p>Weston Goodwin</p></figcaption></figure>

My name is Weston Goodwin, and I created SQL Simulator. This CI/CD tool provides your team with access to production data for research purposes while simultaneously minimizing organizational risk in the event of a data breach.

Here is a 60 second explainer video providing a high level overview. &#x20;

{% embed url="<https://youtu.be/2E6VSCPqAd0?si=D9GQ60qJi-Ozo31H>" %}
60 Second Explainer Video on SQL Simulator
{% endembed %}

Please click the next link below to see why I created SQL simulator.  It's a 2 minute read and I promise you will find the story to be fascinating.&#x20;


# About SQL Simulator(beta) - Docker

Why did I create SQL Simulator

<figure><img src="/files/7KEXzL4AQZSKndEdpW5H" alt="" width="188"><figcaption><p> Weston Goodwin</p></figcaption></figure>

There were a couple of reasons as to why I originally created SQL Simulator.

1. To test Database Change Requests
2. Make it easy to retest data multiple times

After developing the initial version of the tool, I discussed it with several people. The feedback indicated concerns about its security. Although they didn't explicitly say so, I suspect people were uneasy about using software that interacts with their database from some random dude they just met at a networking event.

My next thought was how can I gain people's trust?  So I decided to join the Microsoft Accelerator program,  Because I felt that people would trust my software do to the association with them.  One of the mentors in the program said that they really liked the concept of what it did and asked if I could make it run in containers. This way it would be available through their App store and people would be more likely to trust what's in the app store.

So I agreed to do that.  It took a few months and trying to get it past their security process was a nightmare.  A couple of months after I got the app published in the Microsoft store, I had a meeting with a former CISO about SQL Simulator.  He mentioned that his biggest challenge as a CISO was developers making copies of production data and taking it home with them?!?!?!?!?!?!?!? This revelation stunned me, as I had never heard of such a practice before.

He asked if I had a way to prevent this.  I told him no, because once you give someone access to a database you can't stop them from doing whatever they want with the data.

So about a month after this conversation I was on my way to a networking event when I had an epiphany.  Since my app works with Kubernetes and builds subsetted databases,  I realized I could limit how many primary keys someone could have access to. While I can't stop them from taking 100% of the data home, I could stop 99.9% of it.  So that is a short story on how I came up with the product that you see today. &#x20;

Please click on the Next link below to see the features of SQL Simulator.


# Features

* SQL Simulator is a Docker app that leverages SQL scripts to generate subsetted databases. There's no need to rewrite SQL statements for testing purposes. The tool automatically constructs and populates tables, including those with foreign keys, based on common SQL commands such as insert, update, delete, create table, and select.
* The most notable feature of SQL Simulator is its self-destruct mechanism. Any databases created by the tool will automatically destroy themselves after 15 minutes of inactivity, enhancing security and resource management.
* SQL Simulator incorporates a data governor to regulate data access. This governor imposes restrictions on the number of keys retrievable from tables, both in terms of daily limits and per-request quotas. For instance, users can specify limits such as allowing only one Social Security Number (SSN) to be retrieved across all tables within a database. This ensures data usage compliance and prevents the potential for a massive data breach if you are hacked.
* An additional feature of Data Governance is called “Celebrity Data”. If you mark any key field in your database as being Celebrity Data, this record will need additional approval from management before a user can access it.

Please click the next button below to see the benefits of SQL Simulator.


# Benefits

* Each state in the U.S. establishes its own threshold for reporting data breaches, with variations across all states. A prudent benchmark to adhere to is 300. By ensuring that each database generated by SQL Simulator contains no more than 1 or 2 SSNs, you can remain below this threshold. It's important to note that individuals affected by a data breach must still be notified, although there's no obligation to inform the state or the press. For further details, refer to this link: (<https://bit.ly/45c83yx>).&#x20;
* Reduce computing and storage costs for non production databases.
* Prevents entire database from being exposed for testing
* Limited time exposure for sensitive data
* Limit # of SSN’s retrieved per day.


# Supported Databases

* SQL Server
* Oracle
* MySQL
* Postgres


# Technical Overview

Let me give you an example to describe how SQL Simulator works. Lets say you had the following Insert Statement:

```sql
Insert into tableA values (1,’test’);
```

You want to test this SQL before you run it against production, but you only have blank/empty database. So you would need to do the following steps:

1. Get the DDL for tableA from production
2. Use that DDL in the blank database to recreate the table structure
3. Check to see if the primary key of 1 exists in production and if so copy that record to your blank database.
4. Execute your insert statement against the blank database

When you give SQL Simulator a SQL Script it automates the steps listed above.  SQL Simulator has 3 main function.  They are:

* Postview Merge
* Preview Merge
* Dry Run


# PostView Merge


# Step 1

Static Code Analysis

<figure><img src="/files/ZlKIhSdkhXIAaNW6ePT2" alt=""><figcaption></figcaption></figure>

SQL Simulator analyzes your SQL Script using static code analysis.  It looks for any tables that are referenced.


# Step 2

Get Table DDLs

<figure><img src="/files/ampf9i6M8AXc7XLzKVJj" alt=""><figcaption></figcaption></figure>

It then goes to the production database and retrieves the DDL's for those tables.&#x20;

{% hint style="info" %}
&#x20;If there are any tables that are linked by a foreign key reference it will retrieve the DDL's for those automatically.
{% endhint %}


# Step 3

Create Tables

<figure><img src="/files/FUGixzhrUpy18xcASgU9" alt=""><figcaption></figcaption></figure>

It then creates those tables inside the K8s database pod.

{% hint style="info" %}
Please note that the schema name that is used in the pod database is "simdb".  This is done by using a "SQL Set Rewrite Parser" engine.
{% endhint %}


# Step 4

Copy Data

<figure><img src="/files/nTnkZXvaSsbTldgnMPp2" alt=""><figcaption></figcaption></figure>

Using the "SQL Set Rewrite Parser" engine, SQL Simulator takes the SQL and rewrites it so that SQL Simulator retrieves only the needed records from production and copies them to the database pod. However if you try to retrieve more data than allowed by the Data Access Control, the records set will not be copied to production

If there are any foreign key tables those tables will get populated automatically by the "SQL Set Rewrite Parser".

{% hint style="danger" %}
If you omit the where clause in your SQL then the entire table will be copied.
{% endhint %}


# Step 5

Execute SQL Script

<figure><img src="/files/0vMkOuTrFVbCQMBXdAvo" alt=""><figcaption></figcaption></figure>

Using the "SQL Set Rewrite Parser" engine again it takes your SQL Script, changes the schema name of any table and executes that against the simulated database.


# PreView Merge


# Step 1

Static Code Analysis

<figure><img src="/files/ZlKIhSdkhXIAaNW6ePT2" alt=""><figcaption></figcaption></figure>

SQL Simulator analyzes your SQL Script using static code analysis.  It looks for any tables that are referenced.


# Step 2

Get Table DDLs

<figure><img src="/files/ampf9i6M8AXc7XLzKVJj" alt=""><figcaption></figcaption></figure>

It then goes to the production database and retrieves the DDL's for those tables.&#x20;

{% hint style="info" %}
&#x20;If there are any tables that are linked by a foreign key reference it will retrieve the DDL's for those automatically.
{% endhint %}


# Step 3

Create Tables

<figure><img src="/files/FUGixzhrUpy18xcASgU9" alt=""><figcaption></figcaption></figure>

It then creates those tables inside the K8s database pod.

{% hint style="info" %}
Please note that the schema name that is used in the pod database is "simdb".  This is done by using a "SQL Set Rewrite Parser" engine.
{% endhint %}


# Step 4

Copy Data

<figure><img src="/files/nTnkZXvaSsbTldgnMPp2" alt=""><figcaption></figcaption></figure>

Using the "SQL Set Rewrite Parser" engine, SQL Simulator takes the SQL and rewrites it so that SQL Simulator retrieves only the needed records from production and copies them to the database pod. However if you try to retrieve more data than allowed by the Data Access Control, the records set will not be copied to production

If there are any foreign key tables those tables will get populated automatically by the "SQL Set Rewrite Parser".

{% hint style="danger" %}
If you omit the where clause in your SQL then the entire table will be copied.
{% endhint %}


# Dry Run


# Step 1

Static Code Analysis

<figure><img src="/files/ZlKIhSdkhXIAaNW6ePT2" alt=""><figcaption></figcaption></figure>

SQL Simulator analyzes your SQL Script using static code analysis.  It looks for any tables that are referenced.


# Step 2

Get Table DDLs

<figure><img src="/files/ampf9i6M8AXc7XLzKVJj" alt=""><figcaption></figcaption></figure>

It then goes to the production database and retrieves the DDL's for those tables.&#x20;

{% hint style="info" %}
&#x20;If there are any tables that are linked by a foreign key reference it will retrieve the DDL's for those automatically.
{% endhint %}


# Step 3

Create Tables

<figure><img src="/files/FUGixzhrUpy18xcASgU9" alt=""><figcaption></figcaption></figure>

It then creates those tables inside the K8s database pod.

{% hint style="info" %}
Please note that the schema name that is used in the pod database is "simdb".  This is done by using a "SQL Set Rewrite Parser" engine.
{% endhint %}


# Step 4

Copy Data

<figure><img src="/files/nTnkZXvaSsbTldgnMPp2" alt=""><figcaption></figcaption></figure>

Using the "SQL Set Rewrite Parser" engine, SQL Simulator takes the SQL and rewrites it so that SQL Simulator retrieves only the needed records from production and copies them to the database pod. However if you try to retrieve more data than allowed by the Data Access Control, the records set will not be copied to production

If there are any foreign key tables those tables will get populated automatically by the "SQL Set Rewrite Parser".

{% hint style="danger" %}
If you omit the where clause in your SQL then the entire table will be copied.
{% endhint %}


# Step 5

Execute SQL Script

<figure><img src="/files/0vMkOuTrFVbCQMBXdAvo" alt=""><figcaption></figcaption></figure>

Using the "SQL Set Rewrite Parser" engine again it takes your SQL Script, changes the schema name of any table and executes that against the simulated database.


# Step 6

Destroy All Objects in the database

<figure><img src="/files/qvs4tqTPirX6wA6SMry6" alt=""><figcaption></figcaption></figure>

All objects in the database are destroyed.


# Self Destruct Events

There are certain events that will cause the pod to destroy itself.  When a pod is destroyed the database and the sql simulator software is destroyed as well.  Once a pod is destroyed it cannot be restored.  You will need to go to the market place and recreate the pod if you need to use it again.

* 15 mins of database inactivity&#x20;
* 9 hours of use<br>


# Docker Install Guide

{% hint style="warning" %}
This tutorial assumes that docker has been installed on your computer.
{% endhint %}


# SQL Server

* Download the docker-compose.yml file. &#x20;

{% file src="/files/bfBDPwe1bQeZBUDbU4m0" %}

* Go to the directory you downloaded docker-compose.yml to and run the following from a command line

```
docker-compose up
```

If you have any problems you can email us at <support@tribalknowledge.tech>


# Oracle

* Download the docker-compose.yml file. &#x20;

{% file src="/files/ckoSL3CKp54xFPM3ZOlH" %}

* Go to the directory you downloaded docker-compose.yml to and run the following from a command line

```
docker-compose up
```

If you have any problems you can email us at <support@tribalknowledge.tech>


# MySQL

* Download the docker-compose.yml file. &#x20;

{% file src="/files/gnuFYQtszuJwSQtNlJvR" %}

* Go to the directory you downloaded docker-compose.yml to and run the following from a command line

```
docker-compose up
```

If you have any problems you can email us at <support@tribalknowledge.tech>


# Postgres

* Download the docker-compose.yml file. &#x20;

{% file src="/files/fDKPQX9tQyZwDX8JYdHj" %}

* Go to the directory you downloaded docker-compose.yml to and run the following from a command line

```
docker-compose up
```

If you have any problems you can email us at <support@tribalknowledge.tech>


# Limitations

Currently SQL Simulator only processes DDL\DML statements.  There are several more limitation and the below list is not exhaustive.

{% hint style="info" %}
These limitations will be addressed in future updates.
{% endhint %}

* Tables without primary key or unique records may not have accurate results
* Procedural language statements(TSQL,PLSQL, etc.)
* Bind Variables
* CTE
* Cross Apply&#x20;
* Merge


# SQL Server

Prerequisites

{% hint style="warning" %}
Make sure you've done all the steps in the [K8s Install Guide](/getting-started/docker-install-guide)
{% endhint %}


# Initialize Container

* Open a browser and go to the following URL

```
http://localhost:8080/
```

* Type in the user name and password the click "Initialize".  This is the User Name and Password you will use to connect to the database


# Database Setup

Download and run the following TSQL Script.  This Database will be the source database that the pod will connect to.

{% file src="/files/ZLV6LElJTXapY2MdQZ05" %}

The following zip files are the tables used for Data Governance and Auditing

{% file src="/files/LhbiBMCOD0auQWONeh5E" %}


# SQL Scripts

{% hint style="warning" %}
Please make sure you do a "Destroy Merge" after you run a scenario.
{% endhint %}

Download the following SQL Scripts:

## Scenarios

* You have 2 developers that want to make change to the system.  Try the following files in the simulator to see what would happen.  Remember that order the files are executed in is important.

{% file src="/files/fGgSKtQiyMumQJWQckDY" %}

{% file src="/files/0abFzhcqgcA75RMASzRX" %}

* A developer tries to select more SSN's at one time than the audit table amount allows.  How will SQL Simulator react? &#x20;

{% file src="/files/Y8K2zMKcvghrSphNKjK2" %}
After doing a postview merge try adding the a where clause:  where employee\_id = 1
{% endfile %}

* A developer submits a SQL that is only supposed to delete 1 record.  Try doing a Preview and a Postview merge to see the difference in how SQL Simulator reacts.

{% file src="/files/n3n9Ik5KWlkJqjxBOTib" %}

* A developer submits a update SQL.  Try doing a Preview and a Postview merge.

{% file src="/files/fRBlPLzlX99dVnD5pcKY" %}

* A developer submits an insert SQL.  You have a sneaky suspicion that he did not test his code and if you ran this in production you would get a unique key constraint error.  Try doing a dry run to see what would happen.

{% file src="/files/qy2PxnShNhgoJmdXG2a0" %}


# Add SQL Script

* Open a browser and go to <http://localhost:8080/>
* Click on SQL Scripts in the left hand menu
* Click "Choose Files"
* Add any of the sql script files you downloaded from the previous step


# Datasource Config

We need to configure the datasource for the SQL Simulator.

1. Click SQL Simulator On the left hand menu
2. Click on the Data Sources Button
3. Click Add
4. Click Add SQL Server
5. There are 2 different datasources that you must fill in the connection information for.  The source datasource is the database you test your  SQL file against.  The Pod database is the database inside of the pod.
6. In the Pod Username/Password box use the username/password you created during the installation process.
7. In the pod server box type **mssql**
8. In the Pod database name box type **master**
9. Click Test Connection&#x20;
10. Click Save


# Dry Run

Click on the Dry Run button and review the results.

* Click SQL Simulator On the left hand menu
* Click Dry Run
* Review the output.


# Preview Merge

* Click SQL Simulator On the left hand menu
* Click Preview Merge
* Review the results on screen or with your favorite database tool.


# Postview Merge

* Click SQL Simulator On the left hand menu
* Click Postview Merge
* Review the results on screen or with your favorite database tool.


# Oracle

Prerequisites

{% hint style="warning" %}
Make sure you've done all the steps in the [K8s Install Guide](/getting-started/docker-install-guide)
{% endhint %}


# Initialize Container

* Open a browser and go to the following URL

```
http://localhost:8080/
```

* Type in the user name and password the click "Initialize".  This is the User Name and Password you will use to connect to the database


# Database Setup

Download and run the following PLSQL Script.  This Database will be the source database that the pod will connect to.

{% file src="/files/ybLTqlywOdbnPzjbPzLz" %}

The following zip files are the tables used for Data Governance and Auditing

{% file src="/files/rJNeOoHSp7z7PkYWZbJT" %}


# SQL Scripts

{% hint style="warning" %}
Please make sure you do a "Destroy Merge" after you run a scenario.
{% endhint %}

Download the following SQL Scripts:

## Scenarios

* You have 2 developers that want to make change to the system.  Try the following files in the simulator to see what would happen.  Remember that order the files are executed in is important.

{% file src="/files/IPLKjgNXwAPy0n3uRhXE" %}

{% file src="/files/5uKMBhSN1mCmf7nXUKv0" %}

* A developer tries to select more SSN's at one time than the audit table amount allows.  How will SQL Simulator react? &#x20;

{% file src="/files/UyK4w8aP8jI572q5YhA0" %}
After doing a postview merge try adding the a where clause:  where employee\_id = 1
{% endfile %}

* A developer submits a SQL that is only supposed to delete 1 record.  Try doing a Preview and a Postview merge to see the difference in how SQL Simulator reacts.

{% file src="/files/quy3ZgNaouLwBta4XTAK" %}

* A developer submits a update SQL.  Try doing a Preview and a Postview merge.

{% file src="/files/QI2opwakzxfPiDWDgpqe" %}

* A developer submits an insert SQL.  You have a sneaky suspicion that he did not test his code and if you ran this in production you would get a unique key constraint error.  Try doing a dry run to see what would happen.

{% file src="/files/pS3OkVZMpvtbbFgOUn1T" %}


# Add SQL Script

* Open a browser and go to <http://localhost:8080/>
* Click on SQL Scripts in the left hand menu
* Click "Choose Files"
* Add any of the sql script files you downloaded from the previous step


# Datasource Config

We need to configure the datasource for the SQL Simulator.

1. Click SQL Simulator On the left hand menu
2. Click on the Data Sources Button
3. Click Add
4. Click Add Oracle
5. There are 2 different datasources that you must fill in the connection information for.  The source datasource is the database you test your  SQL file against.  The Pod database is the database inside of the pod.
6. In the Pod Username/Password box use the username/password you created during the installation process.
7. In the pod server box type oracledb
8. In the pod port box type **1521**
9. In the Pod database name box type **free**
10. Click Test Connection&#x20;
11. Click Save


# Dry Run

Click on the Dry Run button and review the results.

* Click SQL Simulator On the left hand menu
* Click Dry Run
* Review the output.


# Preview Merge

* Click SQL Simulator On the left hand menu
* Click Preview Merge
* Review the results on screen or with your favorite database tool.


# Postview Merge

* Click SQL Simulator On the left hand menu
* Click Postview Merge
* Review the results on screen or with your favorite database tool.


# MySQL

Prerequisites

{% hint style="warning" %}
Make sure you've done all the steps in the [K8s Install Guide](/getting-started/docker-install-guide)
{% endhint %}


# Initialize Container

* Open a browser and go to the following URL

```
http://localhost:8080/
```

* Type in the user name and password the click "Initialize".  This is the User Name and Password you will use to connect to the database


# Database Setup

Download and run the following MYSQL Script.  This Database will be the source database that the pod will connect to.

{% file src="/files/NGP5NLOmDwCtpBQ1aXnD" %}

The following zip files are the tables used for Data Governance and Auditing

{% file src="/files/Gf1vSCpJSPSxnhFwi5tS" %}


# SQL Scripts

{% hint style="warning" %}
Please make sure you do a "Destroy Merge" after you run a scenario.
{% endhint %}

Download the following SQL Scripts:

## Scenarios

* You have 2 developers that want to make change to the system.  Try the following files in the simulator to see what would happen.  Remember that order the files are executed in is important.

{% file src="/files/GJDmUjSMrWALeRETDsjZ" %}

{% file src="/files/w74ooHNrs9yO32EgeJcP" %}

* A developer tries to select more SSN's at one time than the audit table amount allows.  How will SQL Simulator react? &#x20;

{% file src="/files/rqR1YjYxcmftEHDpjViR" %}
After doing a postview merge try adding the a where clause:  where employee\_id = 1
{% endfile %}

* A developer submits a SQL that is only supposed to delete 1 record.  Try doing a Preview and a Postview merge to see the difference in how SQL Simulator reacts.

{% file src="/files/WCwq5xSch7wkgmu0rUg6" %}

* A developer submits a update SQL.  Try doing a Preview and a Postview merge.

{% file src="/files/PsJcvlMHJA8xIqJbYMAS" %}

* A developer submits an insert SQL.  You have a sneaky suspicion that he did not test his code and if you ran this in production you would get a unique key constraint error.  Try doing a dry run to see what would happen.

{% file src="/files/DILOituSB6lqLu6b6pVO" %}


# Add SQL Script

* Open a browser and go to <http://localhost:8080/>
* Click on SQL Scripts in the left hand menu
* Click "Choose Files"
* Add any of the sql script files you downloaded from the previous step


# Datasource Config

We need to configure the datasource for the SQL Simulator.

1. Click SQL Simulator On the left hand menu
2. Click on the Data Sources Button
3. Click Add
4. Click Add MySQL
5. There are 2 different datasources that you must fill in the connection information for.  The source datasource is the database you test your  SQL file against.  The Pod database is the database inside of the pod.
6. In the Pod Username/Password box use the username/password you created during the installation process.
7. In the pod server box type **mysql**
8. In the pod port box type **3306**
9. In the Pod database name box type **sys**
10. Click Test Connection&#x20;
11. Click Save


# Dry Run

Click on the Dry Run button and review the results.

* Click SQL Simulator On the left hand menu
* Click Dry Run
* Review the output.


# Preview Merge

* Click SQL Simulator On the left hand menu
* Click Preview Merge
* Review the results on screen or with your favorite database tool.


# Postview Merge

* Click SQL Simulator On the left hand menu
* Click Postview Merge
* Review the results on screen or with your favorite database tool.


# Postgres

Prerequisites

{% hint style="warning" %}
Make sure you've done all the steps in the [K8s Install Guide](/getting-started/docker-install-guide)
{% endhint %}


# Initialize Container

* Open a browser and go to the following URL

```
http://localhost:8080/
```

* Type in the user name and password the click "Initialize".  This is the User Name and Password you will use to connect to the database


# Database Setup

Download and run the following PGSQL Script.  This Database will be the source database that the pod will connect to.

{% file src="/files/2jIGjCHIHZtJEWEDIfHr" %}

The following zip files are the tables used for Data Governance and Auditing

{% file src="/files/0ndn0qVaISaVrB6MDos6" %}


# SQL Scripts

{% hint style="warning" %}
Please make sure you do a "Destroy Merge" after you run a scenario.
{% endhint %}

Download the following SQL Scripts:

## Scenarios

* You have 2 developers that want to make change to the system.  Try the following files in the simulator to see what would happen.  Remember that order the files are executed in is important.

{% file src="/files/imsWaZkSECrmmR0Mhvms" %}

{% file src="/files/Y05WkuqicM9PtWrOlED2" %}

* A developer tries to select more SSN's at one time than the audit table amount allows.  How will SQL Simulator react? &#x20;

{% file src="/files/QkzlYuehZq1IpjsBywV1" %}
After doing a postview merge try adding the a where clause:  where employee\_id = 1
{% endfile %}

* A developer submits a SQL that is only supposed to delete 1 record.  Try doing a Preview and a Postview merge to see the difference in how SQL Simulator reacts.

{% file src="/files/0t75gFmpZZOprtJEbagu" %}

* A developer submits a update SQL.  Try doing a Preview and a Postview merge.

{% file src="/files/3pn6v5pc3PFAJZTIMrm7" %}

* A developer submits an insert SQL.  You have a sneaky suspicion that he did not test his code and if you ran this in production you would get a unique key constraint error.  Try doing a dry run to see what would happen.

{% file src="/files/j4r2dEWUQE2YAFz6Y5hz" %}


# Add SQL Script

* Open a browser and go to <http://localhost:8080/>
* Click on SQL Scripts in the left hand menu
* Click "Choose Files"
* Add any of the sql script files you downloaded from the previous step


# Datasource Config

We need to configure the datasource for the SQL Simulator.

1. Click SQL Simulator On the left hand menu
2. Click on the Data Sources Button
3. Click Add
4. Click Add Postgres
5. There are 2 different datasources that you must fill in the connection information for.  The source datasource is the database you test your  SQL file against.  The Pod database is the database inside of the pod.
6. In the Pod Username/Password box use the username/password you created during the installation process.
7. In the pod server box type **postgres**
8. In the pod port box type **5432**
9. In the Pod database name box type **postgres**
10. Click Test Connection&#x20;
11. Click Save


# Dry Run

Click on the Dry Run button and review the results.

* Click SQL Simulator On the left hand menu
* Click Dry Run
* Review the output.


# Preview Merge

* Click SQL Simulator On the left hand menu
* Click Preview Merge
* Review the results on screen or with your favorite database tool.


# Postview Merge

* Click SQL Simulator On the left hand menu
* Click Postview Merge
* Review the results on screen or with your favorite database tool.


# Introduction

The following pages contain the command line API interface batch files that can be used to setup a subsetted database for Generative AI.


# SQL Server

{% hint style="warning" %}
Make sure you've done all the steps in the [K8s Install Guide](/getting-started/docker-install-guide) and that you have tried the [SQL Server Hello World Tutorial](/web-ui-tutorials/sql-server).
{% endhint %}


# Windows Batch File

**Step 1- Initialize Container**

```
curl -X "POST" ^
  "http://localhost:8080/api/Pod/Init?username=[username]&password=[password]" ^
  -H "accept:  text/plain" 
```

**Step 2- Upload SQL Files to Pod.   Below shows you how to add multiple files.**&#x20;

```
curl -X  "POST" "http://localhost:8080/api/SQLFiles/Add?programming_language=tsql" ^
  -H "accept: */*" ^
  -H "Content-Type: multipart/form-data" ^
  -F files="@C:\\your directory\\your sub directory\\file1.tsql" ^
  -F files="@C:\\your directory\\your sub directory\\file2.tsql" 
```

**Step 3-Add Data Source**

```
curl -X "POST" ^
  "http://localhost:8080/api/DataSources/Add" ^
  -H "Content-Type: application/json" ^
  -d "{  \"database_type\": \"SQLSERVER\",  \"source_uid\": \"[username]\",  \"source_pwd\": \"[password]\",  \"source_database_name\": \"[database name]\",  \"source_server\": \"[server address]\",    \"source_trusted_connection\": \"false\",    \"simulated_uid\": \"[pod user name]\",  \"simulated_pwd\": \"[pod password]\",  \"simulated_database_name\": \"master\",  \"simulated_server\": \"mssql\",  \"simulated_schema_name\": \"\",  \"simulated_trusted_connection\": \"false\"}"
```

**Step 4 - Test Data Source(optional)**

```
curl -X "POST" ^
  "http://localhost:8080/api/DataSources/TestConnection" ^
  -H "accept:  text/plain" 
```

**Step 5-Perform Preview Merge.  You also have the option of doing a DryRun or PostviewMerge.**

```
curl -X "GET" ^
  "http://localhost:8080/api/Run/PreviewMerge" ^
  -H "accept:  text/plain" 
```


# Oracle

{% hint style="warning" %}
Make sure you've done all the steps in the [K8s Install Guide](/getting-started/docker-install-guide) and that you have tried the [Oracle Hello World Tutorial](/web-ui-tutorials/oracle).
{% endhint %}


# Windows Batch File

**Step 1- Initialize Container**

```
curl -X "POST" ^
  "http://localhost:8080/api/Pod/Init?username=[username]&password=[password]" ^
  -H "accept:  text/plain" 
```

**Step 2- Upload SQL Files to Pod.   Below shows you how to add multiple files.**&#x20;

```
curl -X  "POST" "http://localhost:8080/api/SQLFiles/Add?programming_langague=plsql" ^
  -H "accept: */*" ^
  -H "Content-Type: multipart/form-data" ^
  -F files="@C:\\your directory\\your sub directory\\file1.plsql" ^
  -F files="@C:\\your directory\\your sub directory\\file2.plsql" 
```

**Step 3-Add Data Source**

```
curl -X "POST" ^
  "http://localhost:8080/api/DataSources/Add" ^
  -H "Content-Type: application/json" ^
  -d "{  \"database_type\": \"ORACLE\",  \"source_uid\": \"[source db username]\",  \"source_pwd\": \"[source db password]\",  \"source_database_name\": \"[source db name]\",  \"source_host\": \"[source server ip address]\",  \"source_port\": \"1521\",  \"simulated_uid\": \"[pod user name]\",  \"simulated_pwd\": \"[pod password]\",  \"simulated_database_name\": \"FREE\",  \"simulated_schema_name\": \"\",  \"simulated_host\": \"oracledb\",  \"simulated_port\": \"1521\"}"
```

**Step 4 - Test Data Source(optional)**

```
curl -X "POST" ^
  "http://localhost:8080/api/DataSources/TestConnection" ^
  -H "accept:  text/plain" 
```

**Step 5-Perform Preview Merge.  You also have the option of doing a DryRun or PostviewMerge.**

```
curl -X "GET" ^
  "http://localhost:8080/api/Run/PreviewMerge" ^
  -H "accept:  text/plain" 
```


# MySQL

{% hint style="warning" %}
Make sure you've done all the steps in the [K8s Install Guide](/getting-started/docker-install-guide) and that you have tried the [MySQL Hello World Tutorial](/web-ui-tutorials/mysql).
{% endhint %}


# Windows Batch File

**Step 1- Initialize Container**

```
curl -X "POST" ^
  "http://localhost:8080/api/Pod/Init?username=[username]&password=[password]" ^
  -H "accept:  text/plain" 
```

**Step 2- Upload SQL Files to Pod.   Below shows you how to add multiple files.**&#x20;

```
curl -X  "POST" "http://localhost:8080/api/SQLFiles/Add?programming_langague=mysql" ^
  -H "accept: */*" ^
  -H "Content-Type: multipart/form-data" ^
  -F files="@C:\\your directory\\your sub directory\\file1.mysql" ^
  -F files="@C:\\your directory\\your sub directory\\file2.mysql" 
```

**Step 3-Add Data Source**

```
curl -X "POST" ^
  "http://localhost:8080/api/DataSources/Add" ^
  -H "Content-Type: application/json" ^
  -d "{\"database_type\": \"MYSQL\",  \"source_uid\": \"[source db username]\",  \"source_pwd\": \"[source db password]\",  \"source_database_name\": \"[source db name]\",  \"source_server\": \"[server address]\",  \"source_port\": \"3306\",  \"simulated_uid\": \"[pod db username]\",  \"simulated_pwd\": \"[pod db password]\",    \"simulated_database_name\": \"sys\",  \"simulated_server\": \"mysql\",    \"simulated_port\": \"3306\"}"
```

**Step 4 - Test Data Source(optional)**

```
curl -X "POST" ^
  "http://localhost:8080/api/DataSources/TestConnection" ^
  -H "accept:  text/plain" 
```

**Step 5-Perform Preview Merge.  You also have the option of doing a DryRun or PostviewMerge.**

```
curl -X "GET" ^
  "http://localhost:8080/api/Run/PreviewMerge" ^
  -H "accept:  text/plain" 
```


# Postgres

{% hint style="warning" %}
Make sure you've done all the steps in the [K8s Install Guide](/getting-started/docker-install-guide) and that you have tried the [Postgres Hello World Tutorial](/web-ui-tutorials/postgres).
{% endhint %}


# Windows Batch File

**Step 1- Initialize Pod**

```
curl -X "POST" ^
  "http://localhost:8080/api/Pod/Init?username=[username]&password=[password]" ^
  -H "accept:  text/plain" 
```

**Step 2- Upload SQL Files to Pod.   Below shows you how to add multiple files.**&#x20;

```
curl -X  "POST" "http://localhost:8080/api/SQLFiles/Add?programming_langague=pgsql" ^
  -H "accept: */*" ^
  -H "Content-Type: multipart/form-data" ^
  -F files="@C:\\your directory\\your sub directory\\file1.pgsql" ^
  -F files="@C:\\your directory\\your sub directory\\file2.pgsql" 
```

**Step 3-Add Data Source**

```
curl -X "POST" ^
  "http://localhost:8080/api/DataSources/Add" ^
  -H "Content-Type: application/json" ^
  -d "{  \"database_type\": \"POSTGRES\",  \"source_uid\": \"[source db username]\",  \"source_pwd\": \"[source db password]\",  \"source_database_name\": \"[source db name]\",  \"source_server\": \"[source server address]\",    \"source_port\": \"5432\",    \"simulated_uid\": \"[pod db username]\",  \"simulated_pwd\": \"[pod db password]\",  \"simulated_database_name\": \"postgres\",      \"simulated_server\": \"postgres\",    \"simulated_port\": \"5432\"  }"
```

**Step 4 - Test Data Source(optional)**

```
curl -X "POST" ^
  "http://localhost:8080/api/DataSources/TestConnection" ^
  -H "accept:  text/plain" 
```

**Step 5-Perform Preview Merge.  You also have the option of doing a DryRun or PostviewMerge.**

```
curl -X "GET" ^
  "http://localhost:8080/api/Run/PreviewMerge" ^
  -H "accept:  text/plain" 
```


