kandi background
Explore Kits

SqliteManager | Sqlite Manager is a Dev Debug tool | Database library

 by   Ashok-Varma Java Version: 1.3.0 License: Apache-2.0

 by   Ashok-Varma Java Version: 1.3.0 License: Apache-2.0

Download this library from

kandi X-RAY | SqliteManager Summary

SqliteManager is a Java library typically used in Database applications. SqliteManager has no vulnerabilities, it has build file available, it has a Permissive License and it has low support. However SqliteManager has 4 bugs. You can download it from GitHub, Maven.
Sqlite Manager helps to manage your android Sqlite Database very effectively with ease.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • SqliteManager has a low active ecosystem.
  • It has 38 star(s) with 9 fork(s). There are 7 watchers for this library.
  • It had no major release in the last 12 months.
  • SqliteManager has no issues reported. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of SqliteManager is 1.3.0
SqliteManager Support
Best in #Database
Average in #Database
SqliteManager Support
Best in #Database
Average in #Database

quality kandi Quality

  • SqliteManager has 4 bugs (1 blocker, 0 critical, 2 major, 1 minor) and 63 code smells.
SqliteManager Quality
Best in #Database
Average in #Database
SqliteManager Quality
Best in #Database
Average in #Database

securitySecurity

  • SqliteManager has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • SqliteManager code analysis shows 0 unresolved vulnerabilities.
  • There are 7 security hotspots that need review.
SqliteManager Security
Best in #Database
Average in #Database
SqliteManager Security
Best in #Database
Average in #Database

license License

  • SqliteManager is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
SqliteManager License
Best in #Database
Average in #Database
SqliteManager License
Best in #Database
Average in #Database

buildReuse

  • SqliteManager releases are available to install and integrate.
  • Deployable package is available in Maven.
  • Build file is available. You can build the component from source.
  • Installation instructions, examples and code snippets are available.
  • It has 2761 lines of code, 267 functions and 53 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
SqliteManager Reuse
Best in #Database
Average in #Database
SqliteManager Reuse
Best in #Database
Average in #Database
Top functions reviewed by kandi - BETA

kandi has reviewed SqliteManager and discovered the below as its top functions. This is intended to give you an instant insight into SqliteManager implemented functionality, and help decide if they suit your requirements.

  • Display the edit row dialog .
  • Add a row to the table .
  • Populate database with test data .
  • Create table .
  • Translate characters from a string into a character sequence .
  • Replaces the search string with the given replacement string .
  • Sets the data to the columns .
  • Initializes the view .
  • Executes a query .
  • Get an in - memory AppDatabase instance .

SqliteManager Key Features

Add, Update and Delete entries from tables in UI (no sql).

Check all the table entries in your database with preferred sort order

Do custom queries on your database and results are displayed in UI

Download

copy iconCopydownload iconDownload
debugCompile 'com.ashokvarma.android:sqlite-manager:1.3.0'
releaseCompile 'com.ashokvarma.android:sqlite-manager-no-op:1.3.0'

Usage

copy iconCopydownload iconDownload
    public class HelperSqliteDataRetriever implements SqliteDataRetriever {
        SqliteHelper mSqliteHelper;
        SQLiteDatabase mSQLiteDatabase;

        HelperSqliteDataRetriever(SqliteHelper sqliteHelper) {
            mSqliteHelper = sqliteHelper;
            mSQLiteDatabase = mSqliteHelper.getWritableDatabase();
        }

        @Override
        public Cursor rawQuery(@NonNull String query, String[] selectionArgs) {
            if (mSQLiteDatabase == null || !mSQLiteDatabase.isOpen()) {
                mSQLiteDatabase = mSqliteHelper.getWritableDatabase();
            }
            return mSQLiteDatabase.rawQuery(query, selectionArgs);
        }

        @Override
        public String getDatabaseName() {
            return mSqliteHelper.getDatabaseName();
        }

        @Override
        public void freeResources() {
            // not good practice to open multiple database connections and close every time
        }
    }

CSV/Json Export feature

copy iconCopydownload iconDownload
<provider
    android:name="android.support.v4.content.FileProvider"
    android:authorities="${applicationId}"
    android:exported="false"
    android:grantUriPermissions="true">

    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_provider_paths" />
</provider>

License

copy iconCopydownload iconDownload
Sqlite Manager library for Android
Copyright (c) 2016 Ashok Varma (http://ashokvarma.me/).

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

What is the best way to read/write objects in a file with the following conditions

copy iconCopydownload iconDownload
#include "QString"
#include "QFile"
#include "QDataStream"
#include "qdebug.h"
#include "QtSql"
#include "QSqlDatabase"
#include "qmessagebox.h"

class User
{
protected:
QString name;
QList<QString> childrens;

public:
QString getName(){ return name;}
QList<QString> getChildrens(){ return childrens;}

void setName(QString x) {name = x;}
void setChildrens(QList<QString> x) {childrens = x;}



friend QDataStream &operator<<(QDataStream &out, const User &t)
{
    out << t.name << t.childrens;
    return out;
}

friend QDataStream &operator>>(QDataStream &in, User &t)
{
    QString inname;
    QList<QString> inchildrens;
    in >> inname >> inchildrens;
    t.name = inname;
    t.childrens = inchildrens;
    return in;
}
QByteArray object2blob( const User& user )
{
  QByteArray result;
  QDataStream bWrite( &result, QIODevice::WriteOnly );
  bWrite << user;

  return result;

}
User blob2object( const QByteArray& buffer )
{
  User result;
  QDataStream bRead( buffer );
  bRead >> result;

  return result;
}
int saveToDB( const User& user )
{
    QSqlDatabase myDB = QSqlDatabase::addDatabase("QSQLITE");
    myDB.setDatabaseName( "file.db");
    if (!myDB.open())
    {
        qDebug()<<"Failed to open SQL database of registered users";
    }
    else
    {
        qDebug()<<"Successfully opening SQL database of registered users";
        QSqlQuery query;

        query.prepare( "CREATE TABLE IF NOT EXISTS users (name TEXT, childrens BLOB)" );
          if( !query.exec() )
          {
            qDebug() << query.lastError();
          }
          else
          {
            qDebug() << "Table created!";
            query.prepare( "INSERT INTO users (name,childrens) VALUES (:name,:childrens)" );
            query.bindValue(":name", name);
            query.bindValue( ":childrens",  object2blob(user) );
            query.exec();
          }
        query.clear();
        myDB.close();
    }
    QSqlDatabase::removeDatabase("UserConnection");

    return 0;
}
User readFromDB( QString name )
{
    User result;
    QSqlDatabase myDB = QSqlDatabase::addDatabase("QSQLITE");
    myDB.setDatabaseName( "file.db");
    if (!myDB.open())
    {
        qDebug()<<"Failed to open SQL database of registered users";
    }
    else
    {
        QSqlQuery query;

        query.prepare( "SELECT * FROM users WHERE name ='"+ name +"'" );
        //query.bindValue( 0, name );

        if ( query.exec() && query.next() ) {
          result = blob2object( query.value( 1 ).toByteArray() );
        }
        query.clear();
        myDB.close();
    }
    QSqlDatabase::removeDatabase("UserConnection");
    qDebug()<<result.getChildrens();
    return result;
}
};


////////////////////////////////////////////////////////////////
int main()
{
    User u;
    u.setName("Georges");
    u.setChildrens(QList<QString>()<<"Jeanne"<<"Jean");
    u.saveToDB(u);

    User v;
    v.setName("Alex");
    v.setChildrens(QList<QString>()<<"Matthew");
    v.saveToDB(v);

    User w;
    w.setName("Mario");
    w.saveToDB(w);

    User to_read; //to improve here
    User a = to_read.readFromDB("Georges");

    qDebug()<<a.getChildrens();
    return 0;
}

Community Discussions

Trending Discussions on SqliteManager
  • What is the best way to read/write objects in a file with the following conditions
Trending Discussions on SqliteManager

QUESTION

What is the best way to read/write objects in a file with the following conditions

Asked 2020-Feb-13 at 01:00

I am willing to store objects in a database. The purpose is to be able to read / write these objects with the program. The requirements are the following:

  • Objects can be complex using Qt classes such as QList, QString ... or even can contain other objects that use QObjects
  • The database should not be readable or modified by human (no text file, and if I use sqlite database, it has to be encrypted in a way)
  • I should be able to remove, read an object by its name and count the number of objects in the database, without loading everything in the memory

I asked a question here, to do this with a QDataStream with a minimalist example. But it seems it is not the best way to proceed. Would you have some suggestions regarding the solutions that exist for this purpose?

I have tried the following but it does not fulfill the requirements:

  • Storing text in sqlite with QtSQL: but the data is accessible by using sqlitemanager for example, can be modified or removed by humans. Moreover, I have no idea regarding the way to store QList for example or other objects that I created and contain QObject (for example, 2 QList)
  • Storing binary data using QDataStream: in this case, I cannot count the number of objects in my file, neither read or remove a specific object without loading the entire file in memory.

I would be grateful if you could give me some suggestions or provide example, even if the example is minimalist.

ANSWER

Answered 2020-Feb-13 at 01:00

I finally found a solution, especially thanks to Igor Tandetnik and thanks to the topic here

I haven't quite finalized, there is a small imperfection because I have to define an object of my user class that I don't use in order to call the readFromDB function to generate my object from the db.

On the other hand, I get this error message "QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed" each time I call my database.

Anyway, it's a bit late now, and I think it might help some people so I post this minimalist imperfect code below. I'll post an update in the next few days.

Thanks again.

#include "QString"
#include "QFile"
#include "QDataStream"
#include "qdebug.h"
#include "QtSql"
#include "QSqlDatabase"
#include "qmessagebox.h"

class User
{
protected:
QString name;
QList<QString> childrens;

public:
QString getName(){ return name;}
QList<QString> getChildrens(){ return childrens;}

void setName(QString x) {name = x;}
void setChildrens(QList<QString> x) {childrens = x;}



friend QDataStream &operator<<(QDataStream &out, const User &t)
{
    out << t.name << t.childrens;
    return out;
}

friend QDataStream &operator>>(QDataStream &in, User &t)
{
    QString inname;
    QList<QString> inchildrens;
    in >> inname >> inchildrens;
    t.name = inname;
    t.childrens = inchildrens;
    return in;
}
QByteArray object2blob( const User& user )
{
  QByteArray result;
  QDataStream bWrite( &result, QIODevice::WriteOnly );
  bWrite << user;

  return result;

}
User blob2object( const QByteArray& buffer )
{
  User result;
  QDataStream bRead( buffer );
  bRead >> result;

  return result;
}
int saveToDB( const User& user )
{
    QSqlDatabase myDB = QSqlDatabase::addDatabase("QSQLITE");
    myDB.setDatabaseName( "file.db");
    if (!myDB.open())
    {
        qDebug()<<"Failed to open SQL database of registered users";
    }
    else
    {
        qDebug()<<"Successfully opening SQL database of registered users";
        QSqlQuery query;

        query.prepare( "CREATE TABLE IF NOT EXISTS users (name TEXT, childrens BLOB)" );
          if( !query.exec() )
          {
            qDebug() << query.lastError();
          }
          else
          {
            qDebug() << "Table created!";
            query.prepare( "INSERT INTO users (name,childrens) VALUES (:name,:childrens)" );
            query.bindValue(":name", name);
            query.bindValue( ":childrens",  object2blob(user) );
            query.exec();
          }
        query.clear();
        myDB.close();
    }
    QSqlDatabase::removeDatabase("UserConnection");

    return 0;
}
User readFromDB( QString name )
{
    User result;
    QSqlDatabase myDB = QSqlDatabase::addDatabase("QSQLITE");
    myDB.setDatabaseName( "file.db");
    if (!myDB.open())
    {
        qDebug()<<"Failed to open SQL database of registered users";
    }
    else
    {
        QSqlQuery query;

        query.prepare( "SELECT * FROM users WHERE name ='"+ name +"'" );
        //query.bindValue( 0, name );

        if ( query.exec() && query.next() ) {
          result = blob2object( query.value( 1 ).toByteArray() );
        }
        query.clear();
        myDB.close();
    }
    QSqlDatabase::removeDatabase("UserConnection");
    qDebug()<<result.getChildrens();
    return result;
}
};


////////////////////////////////////////////////////////////////
int main()
{
    User u;
    u.setName("Georges");
    u.setChildrens(QList<QString>()<<"Jeanne"<<"Jean");
    u.saveToDB(u);

    User v;
    v.setName("Alex");
    v.setChildrens(QList<QString>()<<"Matthew");
    v.saveToDB(v);

    User w;
    w.setName("Mario");
    w.saveToDB(w);

    User to_read; //to improve here
    User a = to_read.readFromDB("Georges");

    qDebug()<<a.getChildrens();
    return 0;
}

Source https://stackoverflow.com/questions/60168152

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install SqliteManager

Based on your IDE you can import library in one of the following ways.

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Compare Database Libraries with Highest Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.