Android library for auto generating SQL schema and Content provider

Overview

Android-AnnotatedSQL

Android library for auto generating SQL schema and Content Provider by annotations. You will get a full-featured content provider in 5 minutes :)

Wiki:

All information was moved to the Wiki

Maven repo:
com.github.hamsterksu:android-annotatedsql-api:1.10.+
com.github.hamsterksu:android-annotatedsql-processor:1.10.+
Changelog

Current version is 1.10.3. You can find changlog here

Available plugins

How to start?

All necessary information in Wiki.

There are:

  • How to add tot the project
  • Define SQL Schema
  • Define Content Provider
Tools and links
Comments
  • Computed columns and extras like COLLATE

    Computed columns and extras like COLLATE

    what about computed columns ... i know we have a views and it is a lots of works since you are using projection parameter from CP.query as columns in db.query without mapper... take a look at my(runtime) generator documentation and search for computed https://selvinlistsyncsample.codeplex.com/documentation ...(also you can add extras to the Column like Column.COLLATE) ...

    opened by SelvinPL 13
  • Feature/add cursor wrapper

    Feature/add cursor wrapper

    Create cursorwrappers file for each tables and views. generate cursorwrappers classes that contains methods named with column names. Useful for cursor adapters !

    opened by julienbanse 11
  • Add helper method for ContentResolver.notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork)

    Add helper method for ContentResolver.notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork)

    It is arguably most important method for people using custom ContentProvider + SyncAdapter with android:supportsUploading="true", yet there is no helper method for it in generated provider.

    opened by Alexander-- 4
  • Attempting to upgrade database during read fails

    Attempting to upgrade database during read fails

    This isn't strictly speaking an issue with Android-AnnotatedSQL, but it can be sort-of worked around on ContentProvider level, so I am bringing it to your attention now:

    android.database.sqlite.SQLiteException: Can't downgrade database from version 10 to 9
                at android.database.sqlite.SQLiteOpenHelper.onDowngrade(SQLiteOpenHelper.java:307)
                at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:168)
                at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:231)
                at com.example.ExampleProviderProto.query(ExampleProviderProto.java:148)
    

    The cause is the default SQLiteOpenHelper. It looks rather funny, if you consider, that according to comments at the top of source file getReadableDatabase over getWritableDatabase doesn't make any difference in production OS builds.

    opened by Alexander-- 3
  • Fix broken headings in Markdown files

    Fix broken headings in Markdown files

    GitHub changed the way Markdown headings are parsed, so this change fixes it.

    See bryant1410/readmesfix for more information.

    Tackles bryant1410/readmesfix#1

    opened by bryant1410 1
  • Maven support

    Maven support

    Greetings, Is there any way to make your library compatible with Maven based builds? Is there a way to make sure code generation works during compilation like Lombok library does?

    opened by Anatolik 1
  • Compatibility with AS 0.6.x+ Gradle Plugins

    Compatibility with AS 0.6.x+ Gradle Plugins

    Since Beta release of Android Studio the build/ tree has changed a bit (technically since AS 0.6.x release, which includes all relevant changes to gradle plugins). This patch places the generated files into the correct directory.

    opened by groovytux 0
  • Aptlibs gradle plugin for more advanced apt libraries support.

    Aptlibs gradle plugin for more advanced apt libraries support.

    Позволяет более легко цеплять апт либы. Поддерживает asql, aa, groundy, а также можно указывать сколько угодно кастомных либ

    Пример для стандартных либ:

    aptlibs {
        annotatedSql {
            version '1.7.8'
        }
        groundy {
            version '1.3'
        }
        androidAnnotations {
            version '2.7.1'
        }
    }
    

    Или вот так можно захерачить свою:

    aptlibs {
        custom {
            customAnnotatedSql {
                processors = ["com.annotatedsql.processor.provider.ProviderProcessor", "com.annotatedsql.processor.sql.SQLProcessor"]
                groupId 'com.github.hamsterksu'
                artifactIdApt 'android-annotatedsql-processor'
                artifactIdLibrary 'android-annotatedsql-api'
                version '1.7.8'
            }
    
            customAndroidAnnotations {
                processors = ["com.googlecode.androidannotations.AndroidAnnotationProcessor"]
                groupId 'com.googlecode.androidannotations'
                artifactIdApt 'androidannotations'
                artifactIdLibrary 'androidannotations-api'
                version '2.7.1'
    
                customArgs { variant ->
                    arg "-AandroidManifestFile", "${variant.processResources.manifestFile}"
                }
            }
        }
    }
    
    opened by TheHiddenDuck 0
  • Consider using beginTransactionNonExclusive when available

    Consider using beginTransactionNonExclusive when available

    I have encountered a nasty deadlock during debugging some db-related code and traced it down to this thread. So, basically, SQLite is advertised as a multiple-readers-single-writer db, but does not work that way in Android, unless you call beginTransactionNonExclusive instead if beginTransaction. The notifications about changes are delivered in order via ContentResolver, so there should not be any concurrency issues from the first glance.

    What possible downsides to doing that can you imagine? Would it make sense to use that method by default in AnnotatedSQL?

    opened by Alexander-- 2
  • Lib has an issue with support at least one sqlite aggregation function in @RawQuery

    Lib has an issue with support at least one sqlite aggregation function in @RawQuery

    Steps to reprodice:

    1. Define rawquery as

    SELECT AI._id, GROUP_CONCAT(Name, ", ") AS GroupedName FROM ABSTRACTS_ITEM AI JOIN AUTHORS_ABSTRACT AAB ON AI.ID = AAB.ABSTRACTSITEM_ID JOIN ABSTRACT_AUTHOR AAU ON AAU._id = AAB.ABSTRACTAUTHOR_ID GROUP BY tbl._id;

    1. Initiate request
    2. Build application

    Expected result: App successfully is built and request works well

    Actual result: App is crashed during build. Error in autogenerated dbschema with errors:

    Error:(69, 1903) error: ';' expected Error:(69, 1914) error: expected Error:(69, 1997) error: expected

    opened by Gelassen 1
  • Cyclic dependencies between Schema2 and database contract

    Cyclic dependencies between Schema2 and database contract

    Let's look at schema with simple join on views. The linked gist won't compile, because using a Schema2 requires a table to be parsed... Which can not be done until @SimpleView, using the Scema2 is parsed.

    I see 3 solutions (aside from not using AnnotatedSQL there):

    • Hardcode stuff from Schema2 into the contract (not nice, isn't it?);
    • Postpone individual tables/views until further compilation passes;
    • Simply do not create Schema2 (e.g. #20).
    opened by Alexander-- 0
  • Do not rename columns in generated JOINs unless necessary

    Do not rename columns in generated JOINs unless necessary

    Right now AnnotatedSQL mangles column names during joins by appending "as table_name___column_name" to each column in generated SELECT statement, e.g.

    CREATE VIEW nearest as SELECT locations._id as _id, locations.coslat as locations_coslat, locations.sinlat as locations_sinlat...
    

    While occasionally useful and more mistake-proof, this prevents hardcoding column names in really complex statements. Instead the generator should check for duplicate names and rename columns only when necessary. For most purposes it should be enough to maintain a single global list of names and rename columns when any two tables have column with the same name. Otherwise just keep old names.

    Hopefully, this won't not introduce any breakage, but just in case you can leave old behavior by default and make it toggleable with apt option.

    opened by Alexander-- 3
Owner
Gennadiy Dubina
Gennadiy Dubina
A simple NoSQL client for Android. Meant as a document store using key/value pairs and some rudimentary querying. Useful for avoiding the hassle of SQL code.

SimpleNoSQL A simple NoSQL client for Android. If you ever wanted to just save some data but didn't really want to worry about where it was going to b

Colin Miller 389 Sep 25, 2022
sql-delight example, a plugin by Square which is pure kotlin and it is useful in kmm

Sql-Delight-Example01 Developed by Mahdi Razzaghi Ghaleh first example of sql-delight What is SqlDelight? Kotlin Multiplatform is one of the most inte

rq_mehdi 0 Jan 24, 2022
requery - modern SQL based query & persistence for Java / Kotlin / Android

A light but powerful object mapping and SQL generator for Java/Kotlin/Android with RxJava and Java 8 support. Easily map to or create databases, perfo

requery 3.1k Dec 29, 2022
A lightweight wrapper around SQLiteOpenHelper which introduces reactive stream semantics to SQL operations.

SQL Brite A lightweight wrapper around SupportSQLiteOpenHelper and ContentResolver which introduces reactive stream semantics to queries. Deprecated T

Square 4.6k Jan 5, 2023
Upsert DSL extension for Exposed, Kotlin SQL framework

Exposed Upsert Upsert DSL extension for Exposed, Kotlin SQL framework. Project bases on various solutions provided by community in the official "Expos

Dzikoysk 23 Oct 6, 2022
Upsert DSL extension for Exposed, Kotlin SQL framework

Exposed Upsert Upsert DSL extension for Exposed, Kotlin SQL framework. Project bases on various solutions provided by community in the official "Expos

Reposilite Playground 23 Oct 6, 2022
LiteGo is a Java-based asynchronous concurrency library. It has a smart executor, which can be freely set the maximum number of concurrent at same time , and the number of threads in waiting queue. It can also set waiting policies and overload strategies.

LiteGo:「迷你」的Android异步并发类库 LiteGo是一款基于Java语言的「异步并发类库」,它的核心是一枚「迷你」并发器,它可以自由地设置同一时段的最大「并发」数量,等待「排队」线程数量,还可以设置「排队策略」和「超载策略」。 LiteGo可以直接投入Runnable、Callable

马天宇 189 Nov 10, 2022
A blazing fast, powerful, and very simple ORM android database library that writes database code for you.

README DBFlow is fast, efficient, and feature-rich Kotlin database library built on SQLite for Android. DBFlow utilizes annotation processing to gener

Andrew Grosner 4.9k Dec 30, 2022
A blazing fast, powerful, and very simple ORM android database library that writes database code for you.

README DBFlow is fast, efficient, and feature-rich Kotlin database library built on SQLite for Android. DBFlow utilizes annotation processing to gener

Andrew Grosner 4.9k Dec 30, 2022
SquiDB is a SQLite database library for Android and iOS

Most ongoing development is currently taking place on the dev_4.0 branch. Click here to see the latest changes and try out the 4.0 beta. Introducing S

Yahoo 1.3k Dec 26, 2022
AndroidQuery is an Android ORM for SQLite and ContentProvider which focuses on easy of use and performances thanks to annotation processing and code generation

WARNING: now that Room is out, I no longer maintain that library. If you need a library to easy access to default android ContentProvider, I would may

Frédéric Julian 19 Dec 11, 2021
An Android library that makes developers use SQLite database extremely easy.

LitePal for Android 中文文档 LitePal is an open source Android library that allows developers to use SQLite database extremely easy. You can finish most o

Lin Guo 7.9k Dec 31, 2022
Sprinkles is a boiler-plate-reduction-library for dealing with databases in android applications

Sprinkles Sprinkles is a boiler-plate-reduction-library for dealing with databases in android applications. Some would call it a kind of ORM but I don

Emil Sjölander 781 Nov 28, 2022
A Java/Kotlin library for Android platform, to manage bean's persistence in SQLite, SharedPreferences, JSON, XML, Properties, Yaml, CBOR.

Thanks to JetBrains for support Kripton Persistence Library project! Kripton Persistence Library Kripton is a java library, for Android platform, that

xcesco 117 Nov 11, 2022
An Android library that makes developers use SQLite database extremely easy.

LitePal for Android 中文文档 LitePal is an open source Android library that allows developers to use SQLite database extremely easy. You can finish most o

Lin Guo 7.9k Jan 4, 2023
This is an Online Book App in which user can read and add their books on favourites fragment and also give rating on it.

BookHub-AndroidApp BookHub Basic Android App Based on the concept of Fragment, Navigation Drawer, Database (Room), Internet Access, etc. See the app o

Yash Kumar Shrivas 3 Mar 10, 2022
An Android helper class to manage database creation and version management using an application's raw asset files

THIS PROJECT IS NO LONGER MAINTAINED Android SQLiteAssetHelper An Android helper class to manage database creation and version management using an app

Jeff Gilfelt 2.2k Dec 23, 2022
lightweight and minimalist ORM for Java/Android. works with SQLite & MySQL. (not actively maintained)

Description ORMAN is an minimalistic and lightweight ORM framework for Java which can handle your common database usage without writing SQL and strugg

Ahmet Alp Balkan 246 Nov 20, 2022
lightweight and minimalist ORM for Java/Android. works with SQLite & MySQL. (not actively maintained)

Description ORMAN is an minimalistic and lightweight ORM framework for Java which can handle your common database usage without writing SQL and strugg

Ahmet Alp Balkan 246 Nov 20, 2022