Tangram is a data access framework, providing a SQL-like json interface for operation of different types of datastores.
{
"select": "table",
"fields": ["column1", "column2", ...],
"join": ["join_table", ...],
"where": ["column1=value1", "column2=value2", ...],
"group": ["column1", "column2", ...],
"order": ["column1", "column2", ...]
}
{
"insert": "table",
"values": {
"column1": value1,
"column2": value2,
...
}
}
{
"update": "table",
"values": {
"column1": value1,
"column2": value2,
...
},
"where": ["column1=value1", "column2=value2", ...]
}
{
"delete": "table",
"where": ["column1=value1", "column2=value2", ...]
}
Add the library to your project.
<dependency>
<groupId>com.github.mengxianun</groupId>
<artifactId>tangram-jdbc</artifactId>
<version>x.y.z</version>
</dependency>
dependencies {
implementation 'com.github.mengxianun:tangram-jdbc:x.y.z'
}
Create a configuration file in the classpath directory and configure the data source. The default configuration file name is air.json
{
"datasources": {
"myds": {
"url": "jdbc:mysql://localhost:3306/tangram",
"username": "tangram",
"password": "123456",
...
}
}
}
Translator translator = new DefaultTranslator();
String json = "{\"select\":\"sys_user\",\"fields\":\"*\",\"where\":\"id=1\"}";
DataResultSet dataResultSet = translator.translate(json);
Object data = dataResultSet.getData();
See the detail documentation or Wiki.
This project is licensed under the MIT License.