All Projects → jasonwyatt → Squeaky-Android

jasonwyatt / Squeaky-Android

Licence: MIT license
Appropriately lightweight database creations and migrations with SQLite on Android

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Squeaky-Android

AndroidEasySQL-Library
An Easier & Lazier approach to SQL database for Android
Stars: ✭ 28 (-17.65%)
Mutual labels:  sqlite-database, sqlite-android
DBFlowManager
A quick and easy database manager plugin library for your DBFlow databases.
Stars: ✭ 26 (-23.53%)
Mutual labels:  sqlite-database, sqlite-android
Android-SQLite-Tutorial
This is a simple project of Android SQLite Relational Database. You can check my Bengali Blog Post on this topic
Stars: ✭ 34 (+0%)
Mutual labels:  sqlite-database, sqlite-android
OLA Play Music App
Music Streaming App
Stars: ✭ 27 (-20.59%)
Mutual labels:  sqlite-database, sqlite-android
mik
The Move to Islandora Kit is an extensible PHP command-line tool for converting source content and metadata into packages suitable for importing into Islandora (or other digital repository and preservations systems).
Stars: ✭ 32 (-5.88%)
Mutual labels:  migration
great-migration
Copy objects from Rackspace to S3
Stars: ✭ 15 (-55.88%)
Mutual labels:  migration
watchdb
Keeping SQLite databases in sync
Stars: ✭ 72 (+111.76%)
Mutual labels:  sqlite-database
Password-Storage
android application to store user’s password of various online accounts
Stars: ✭ 13 (-61.76%)
Mutual labels:  sqlite-android
sprockets-bumble d
Sprockets plugin to transpile modern javascript using Babel, useful while migrating to ES6 modules
Stars: ✭ 32 (-5.88%)
Mutual labels:  migration
nim-gatabase
Connection-Pooling Compile-Time ORM for Nim
Stars: ✭ 103 (+202.94%)
Mutual labels:  sqlite-database
mongock
Lightweight Java based migration tool
Stars: ✭ 357 (+950%)
Mutual labels:  migration
amazon-s3-data-replication-hub-plugin
The Amazon S3 Transfer Plugin for Data Transfer Hub(https://github.com/awslabs/data-transfer-hub). Transfer objects from S3(in other partition), Alibaba Cloud OSS, Tencent COS, Qiniu Kodo into Amazon S3.
Stars: ✭ 32 (-5.88%)
Mutual labels:  migration
typescript-api-starter
🔰 Starter for Node.js express API in Typescript 🚀
Stars: ✭ 72 (+111.76%)
Mutual labels:  migration
tm-tools
some useful tools for tendermint blockstore.db or state.db
Stars: ✭ 14 (-58.82%)
Mutual labels:  migration
go-echo-boilerplate
The fastest way to build a restful API with golang and echo framework. Includes common required features for modern web applications. A boilerplate project with golang and Echo.
Stars: ✭ 53 (+55.88%)
Mutual labels:  migration
laminas-dependency-plugin
Replace zendframework and zfcampus packages with their Laminas Project equivalents.
Stars: ✭ 32 (-5.88%)
Mutual labels:  migration
hearthstats
Scrape Hearthstone decks from HearthPwn, then build a SQLite database of the results. Can also scrape card collection data from HearthPwn/Innkeeper, and integrates with omgvamp's Mashape Hearthstone API to build a table of card data that can be used to make more advanced queries.
Stars: ✭ 11 (-67.65%)
Mutual labels:  sqlite-database
smilite
A Python module to retrieve and compare SMILE strings of chemical compounds from the free ZINC online database
Stars: ✭ 65 (+91.18%)
Mutual labels:  sqlite-database
migration-tool
Automated script to migrate from Directus v8 to Directus v9
Stars: ✭ 21 (-38.24%)
Mutual labels:  migration
porter
Export legacy forums into a format Vanilla Forums can import.
Stars: ✭ 39 (+14.71%)
Mutual labels:  migration

Squeaky for Android

SQLite is simple and lightweight; it follows that managing SQLite databases on Android should be also.

Squeaky strives to be a straightforward approach to creating, migrating, and accessing SQLite databases.

Setup

Add jitpack.io to your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Add Squeaky-Android as a dependency to your app's build.gradle:

dependencies {
    compile 'com.github.jasonwyatt:squeaky-android:1.2.0'
}

Getting Started

Define your Tables

import co.jasonwyatt.squeaky.Table

public class TodosTable extends Table {
    @Override
    public String getName() {
        return "todos";
    }

    @Override
    public int getVersion() {
        return 1;
    }

    @Override
    public String[] getCreateTable() {
        return new String[] {
            "CREATE TABLE todos ("+
            "    name TEXT NOT NULL"+
            "    completed INTEGER NOT NULL DEFAULT 0"+
            ")"
        };
    }

    @Override
    public String[] getMigration(int nextVersion) {
        return new String[0];
    }
}

Create your Database and add Tables to it

// in your Application's or Activity's onCreate() method
Database myDB = new Database(this, "todos_db");

myDb.addTable(new TodosTable());
myDb.prepare();

Use it!

myDb.insert("INSERT INTO todos (name) VALUES (?)", "Learn how to use Squeaky");
myDb.insert("INSERT INTO todos (name, completed) VALUES (?, ?)", "Already done", 1);

// query
Cursor c = myDb.query("SELECT rowid, name, completed FROM todos");
while (c.moveToNext()) {
    // get values
    long rowid = c.getLong(0);
    String name = c.getString(1);
    boolean completed = c.getInt(2) == 1;
}

// in an OnClickListener, for example..
myDb.update("UPDATE todos SET completed = 1 WHERE rowid = ?", rowid);

Migrate a Table

Modify your Table definition class:

import co.jasonwyatt.squeaky.Table

public class TodosTable extends Table {
    @Override
    public String getName() {
        return "todos";
    }

    @Override
    public int getVersion() {
        return 2;
    }

    @Override
    public String[] getCreateTable() {
        return new String[] {
            "CREATE TABLE todos ("+
            "    name TEXT NOT NULL"+
            "    completed INTEGER NOT NULL DEFAULT 0"+
            "    due_date INTEGER"+
            ")"
        };
    }

    @Override
    public String[] getMigration(int nextVersion) {
        if (nextVersion == 2) {
            return new String[] {
                "ALTER TABLE todos ADD COLUMN due_date INTEGER"
            };
        }
        return new String[0];
    }
}

That's it. Next time your database is prepared after adding the table definition, the table will be migrated for you!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].