-
Add your SQL into resources directory file name: sample_sql.sql. Sometimes we need to hardcode some values in SQL, for that we can use syntax like:
Here we have hardcoded country as India, customer_id as 300. first_name will be passed as parameter to the rest API. first_name will be replaced with first_name = ? in SQL.sql SELECT * FROM table WHERE country = 'HARDCODE_AS_STRING{India}' and customer_id = 'HARDCODE_AS_{300}' and first_name = 'John'
-
Add your DDLs into resources directory file name: sample_ddl.sql
-
In java file name: MicroserviceGenerator.java update variable businessPurposeOfSQL with the business purpose of API that you want to generate.
*In case you want to try this out you can use existing SQL and DDLs, no need to make any changes anywhere, just run the program MicroserviceGenerator.java and generate Spring boot microservice, this is explained in next section. To test the generated Rest API you need database which can be setup from instruction given at .dev/README.md*
Run the following command to generate a runnable jar:
mvn package
A jar named MSG-1.0-SNAPSHOT.jar
will be generated in the target
directory.
There are two ways you can run MSG:
-
From sources with Maven:
mvn spring-boot:run -Dspring-boot.run.arguments="--destination /tmp/test"
-
Running the jar:
java -jar MSG-1.0-SNAPSHOT.jar --destination /tmp/test
Run MSG to generate the microservice application. The microservice application will be generated in the destination defined in the command line, or in the user home directory in case the destination is not defined.
-
Windows:
C:\Users\[username]
-
Linux:
/home/[username]
-
Mac:
/Users/[username]
At the end of program execution, you will see the message having directory path of generated spring boot application. e.g.
Generated spring boot application is available at: /Users/nitinkumarsharma/BusinessData
-
cd /home/<user>/<project-name>
-
mvn clean package spring-boot:run
-
TODO This is tested against MS SQL Server, need to add support for other databases, it should be straightforward, just add files Similar to SQLServerDataTypeEnum for other databases and code should be able to understand DB type when we start the application to choose correct DB specific Enum class.
-
TODO: Schema name is ignored in ReadDDL class so Table names should be unique across all schemas. This is a limitation right now, should be fixed.
-
TODO: Table name is case-sensitive right now, ddl file and SQL should have same case, should be fixed.
-
TODO Add support for aggregate functions in select clause is not available.
-
WIP Need to add support for all data types and write tests.
-
Boost Dev Productivity #nocode.
-
Reduce time spent on writing code.
-
Reduce time spent on writing tests.
-
Reduce time spent on writing documentation.
-
Reduce time spent on writing code review.
-
Bug free code, no time wasted on bug fixing. Study shows that debugging take more time than writing code.