chennaione/sugar
chennaione/sugar has 2,604 GitHub stars and 568 forks. GitHot measured 0 stars in 24 hours and -2 in 7 days. Last checked 2026-11-11 08:54 UTC. Last push 2021-09-02.
Insanely easy way to work with Android Database.
What you can do
- A simple, concise, and clean integration process with minimal configuration.
- Automatic table and column naming through reflection.
- Support for migrations between different schema versions.
측정된 스타 증가
- in 24h
- 0
- in 7 days
- -2
- in 15 days
- 업데이트 지연
- in 1 month
- 업데이트 지연
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalSugar ORM

Insanely easy way to work with Android databases.
Official documentation can be found here - Check some examples below. The example application is provided in the example folder in the source.
Looking for contributors
We need contributors to help maintain this project, ask @satyan for repo permission
Otherwise you can use another ORM, like https://github.com/requery/requery or https://realm.io/
Features
Sugar ORM was built in contrast to other ORM's to have:
- A simple, concise, and clean integration process with minimal configuration.
- Automatic table and column naming through reflection.
- Support for migrations between different schema versions.
Installing
There are four ways to install Sugar:
As a Gradle dependency
This is the preferred way. Simply add:
compile 'com.github.satyan:sugar:1.5'
to your project dependencies and run gradle build or gradle assemble.
As a Maven dependency
Declare the dependency in Maven:
<dependency>
<groupId>com.github.satyan</groupId>
<artifactId>sugar</artifactId>
<version>1.5</version>
</dependency>
As a library project
Download the source code and import it as a library project in Eclipse. The project is available in the folder library. For more information on how to do this, read here.
As a jar
Visit the releases page to download jars directly. You can drop them into your libs folder and configure the Java build path to include the library. See this tutorial for an excellent guide on how to do this.
How to use master version
First, download sugar repository
git clone [email protected]:satyan/sugar.git
include this in your settings.gradle
include ':app' // your module app
include ':sugar'
def getLocalProperty(prop) {
Properties properties = new Properties()
properties.load(new File(rootDir.absolutePath + '/local.properties').newDataInputStream())
return properties.getProperty(prop, '')
}
project(':sugar').projectDir = new File(getLocalProperty('sugar.dir'))
include this in your local.properties
sugar.dir=/path/to/sugar/library
add sugar project to the dependencies of your main project (build.gradle)
dependencies {
compile project(':sugar')
}
You should also comment this line just comment this line (library/build.gradle): https://github.com/satyan/sugar/blob/master/library%2Fbuild.gradle#L2
// apply from: '../maven_push.gradle'
===================
After installing, check out how to set up your first database and models here Outdated. Check examples of 1.4 and master below:
Examples
SugarRecord
public class Book extends SugarRecord {
@Unique
String isbn;
String title;
String edition;
// Default constructor is necessary for SugarRecord
public Book() {
}
public Book(String isbn, String title, String edition) {
this.isbn = isbn;
this.title = title;
this.edition = edition;
}
}
or
@Table
public class Book { ... }
Save Entity
Book book = new Book("isbn123", "Title here", "2nd edition")
book.save();
or
SugarRecord.save(book); // if using the @Table annotation
Load Entity
Book book = Book.findById(Book.class, 1);
Update Entity
Book book = Book.findById(Book.class, 1);
book.title = "updated title here"; // modify the values
book.edition = "3rd edition";
book.save(); // updates the previous entry with new values.
Delete Entity
Book book = Book.findById(Book.class, 1);
book.delete();
or
SugarRecord.delete(book); // if using the @Table annotation
Update Entity based on Unique values
Book book = new Book("isbn123", "Title here", "2nd edition")
book.save();
// Update book with isbn123
Book sameBook = new Book("isbn123", "New Title", "5th edition")
sameBook.update();
book.getId() == sameBook.getId(); // true
or
SugarRecord.update(sameBook); // if using the @Table annotation
Bulk Insert
List<Book> books = new ArrayList<>();
books.add(new Book("isbn123", "Title here", "2nd edition"))
books.add(new Book("isbn456", "Title here 2", "3nd edition"))
books.add(new Book("isbn789", "Title here 3", "4nd edition"))
SugarRecord.saveInTx(books);
When using ProGuard
# Ensures entities remain un-obfuscated so table and columns are named correctly
-keep class com.yourpackage.yourapp.domainclasspackage.** { *; }
Known Issues.
1. Instant Run.
Instant-Run seems to prevent Sugar ORM from finding the "table" classes, therefore it cannot create the DB tables if you run the app for the first time
When running your app for the first time Turn off Instant run once to allow for the DB tables to be created You can enable it after the tables have been created.
To disable Instant-Run in Android Studio:
(Preferences (Mac) or Settings (PC) -> Build, Execution, Deployment -> Instant Run -> Untick "Enable Instant Run..." )
CHANGELOG
Contributing
Please fork this repository and contribute back using pull requests. Features can be requested using issues. All code, comments, and critiques are greatly appreciated.
관련 프로젝트 살펴보기
Asabeneh/30-Days-Of-Python
30 Days of Python 프로그래밍 챌린지는 Python 프로그래밍 언어를 30일 동안 배우기 위한 단계별 가이드입니다. 이 챌린지는 100일 이상 걸릴 수 있습니다. 자신의 속도에 맞춰 진행하세요. 다음 동영상도 도움이 될 수 있습니다: https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw
78,560 스타grafana/grafana
개방적이고 조합 가능한 옵저버빌리티 및 데이터 시각화 플랫폼입니다. Prometheus, Loki, Elasticsearch, InfluxDB, Postgres 등 여러 소스의 메트릭, 로그, 트레이스를 시각화합니다.
77,830 스타redis/redis
실시간 데이터 기반 애플리케이션을 구축하는 개발자에게 Redis는 가장 선호되고, 가장 빠르며, 기능이 가장 풍부한 캐시, 데이터 구조 서버이자 문서 및 벡터 쿼리 엔진입니다.
77,395 스타apache/superset
Apache Superset는 데이터 시각화 및 데이터 탐색 플랫폼입니다.
75,473 스타