Coder Social home page Coder Social logo

nativescript-sqlite's Introduction

Archived Public Repo

See: https://fluentreports.com/blog/?p=1434

NativeScript-sqlite

Developed & Sponsored by

MasterTech

Documentation

The documentation for the plugin is located in the src folder.

Commercial Options

The commercial version comes with the following enhancements:

  • TypeScript definitions
  • Totally backwards compatible with the free version
  • Prepared statements
  • Multilevel transaction support
  • Encryption
  • Run multiple queries per call (i.e. get(["select 1", "select 2", "select 3"]))
  • Multi-threading

Installation

  • tns plugin add nativescript-sqlite@latest

Installation of Encrypted Plugin (Provides encryption support)

  • tns plugin add nativescript-sqlite-encrypted-1.5.0.tgz

Installation of Commercial Plugin (Provides Transactions, Prepared statements, multiple queries)

  • tns plugin add nativescript-sqlite-commercial-1.4.2.tgz

nativescript-sqlite's People

Contributors

forestphoenix avatar leocaseiro avatar mbektchiev avatar nathanaela avatar nirre7 avatar nraboy avatar pawelangelow avatar rynop avatar sis0k0 avatar triniwiz avatar webleaf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nativescript-sqlite's Issues

copy database just copies from assets

hi,
the copyDatabase just copies the database from assets (Android I didn't check ios) but there are situations that we need to copy it from sdcard to database folder (like downloading it from server).
I know we can copy do it manually, but if copyDatabase supports that it would be really good.

database version number

Hey, If I ship new database within the app, how can I increment it's version so if it already exists, current get deleted and new comes in?

Error after installed web pack

I've installed web pack on my project and then i'm getting the following error.

ERROR in ./modules/pack.address/pack.address.component.ts
Module not found: Error: Can't resolve 'nativescript-directions' in 'C:\dev\fm-transportes\src\FM.Transportes\app\modules\pack.address'
@ ./modules/pack.address/pack.address.component.ts 13:17-51
@ ./app.module.ts
@ ./main.ts

database.service.ts

const Sqlite = require("nativescript-sqlite");

const dbName = "fm.db";
import { Package, Pack, Order, Address, Reason, PackageSummary, PackStatus, Checkout } from "../";

export class DatabaseService {
  constructor() {
    this.Setup();    
  }

Is the nativescript-directions plugin compatible ?
I also opened an issue on the web pack page
#NativeScript/nativescript-dev-webpack#81

Use of MATCH

I have tried to execute an query with the MATCH option, but I had no success.

missing method for backing up database

Each time i deploy app, my database changes are getting lost.
Sqlite.copyDatabase is handy for restoring database from a backup, but it would be extremely helpful to have a way to backup it

Support for sqlite3_create_function

Would it be possible to support custom functions in sqlite on iOS and Android. It would be desirable to be able to define custom functions and have them implemented by javascript functions.

This is definitely a wishlist item, I'm just curious if anyone would benefit from this (and even if it's technically feasible - I'm not familiar with the limitations of the sqlite implementations on mobile platforms).

Table not found

I have a problem. Some time ago, everything worked well. but now it is crashed

Error: JS: Error: android.database.sqlite.SQLiteException: no such table: contents (code 1): , while compiling: select title from contents JS: android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) JS: android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889) JS: android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500) JS: android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) JS: android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58) JS: android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37) JS: android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44) JS: android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314) JS: android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253) JS: com.tns.Platform.callJSMethodNative(Native Method) JS: com.tns.Platform.dispatchCallJSMethodNative(Platform.java:838) JS: com.tns.Platform.callJSMethod(Platform.java:725) JS: com.tns.Platform.callJSMethod(Platform.java:704) JS: com.tns.Platform.callJSMethod(Platform.java:694) JS: com.tns.gen.android.app.Fragment_ftns_modules_ui_frame_frame_l18_c45__.onCreateView(android.app.Fragment.java) JS: android.app.Fragment.performCreateView(Fragment.java:1695) JS: android.app.FragmentManagerImpl.moveToState(FragmentManager.java:885) JS: android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1057) JS: android.app.BackStackRecord.run(BackStackRecord.java:682) JS: android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1435) JS: android.app.Activity.performStart(Activity.java:5142) JS: android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184) JS: android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) JS: android.app.ActivityThread.access$600(ActivityThread.java:141) JS: android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) JS: android.os.Handler.dispatchMessage(Handler.java:99) JS: android.os.Looper.loop(Looper.java:137) JS: android.app.ActivityThread.main(ActivityThread.java:5103) JS: java.lang.reflect.Method.invokeNative(Native Method) JS: java.lang.reflect.Method.invoke(Method.java:525) JS: com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) JS: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) JS: dalvik.system.NativeStart.main(Native Method)

Please, improve documentation for RESULTSASOBJECT

Hi, I'm not sure why RESULTSASOBJECT is the default FETCH, as I believe 99% of users would expect objects and not arrays.

Anyway, I took a while to understand that was a function and not a parameter. So that would be nice an example. So here we go:

if (!Sqlite.exists('database.db')) {
    Sqlite.copyDatabase('database.db');
}
(new Sqlite('database.db')).then(function(db) {

    db.resultType(Sqlite.RESULTSASOBJECT); //Here where the magic happens

    db.execSQL("CREATE TABLE IF NOT EXISTS table (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)").then(function() {
        pageData = viewModel(db);
        page.bindingContext = pageData;
    }, function(error) {
        console.log("CREATE TABLE ERROR", error);
    });
}, function(error) {
    console.log("OPEN DB ERROR", error);
});

If you are doing db.resultType = Sqlite.RESULTSASOBJECT you are doing wrong.

Typescript Support

Apologies if I have missed it, but it would be really useful if this plugin supported TypeScript, i.e. had a typescript definition file with it. I am happy to help with this if required.

multiple execution

Hello guys... firstly sorry for my bad english...
I have a error in {N} when i have multiple execution on my database.

JS: SQLITE.CONSTRUCTOR - Open DB Error Error: android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file (code 14): , while compiling: PRAGMA journal_mode JS: android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) JS: android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887) JS: android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:632) JS: android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:318) JS: android.database.sqlite.SQLiteConnection.setWalModeFromConfiguration(SQLiteConnection.java:292) JS: android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:213) JS: android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:191) JS: android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463) JS: android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185) JS: android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177) JS: android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:806) JS: android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791) JS: android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694) JS: android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:709) JS: com.tns.Runtime.callJSMethodNative(Native Method) JS: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1011) JS: com.tns.Runtime.callJSMethodImpl(Runtime.java:896) JS: com.tns.Runtime.callJSMethod(Runtime.java:884) JS: com.tns.Runtime.callJSMethod(Runtime.java:868) JS: com.tns.Runtime.callJSMethod(Runtime.java:860) JS: com.tns.gen.org.nativescript.widgets.Async_CompleteCallback.onComplete(org.nativescript.widgets.Async$CompleteCallback.java) JS: org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:465) JS: org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:379) JS: android.os.AsyncTask.finish(AsyncTask.java:651) JS: android.os.AsyncTask.-wrap1(AsyncTask.java) JS: android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668) JS: android.os.Handler.dispatchMessage(Handler.java:102) JS: android.os.Looper.loop(Looper.java:148) JS: android.app.ActivityThread.main(ActivityThread.java:5417) JS: java.lang.reflect.Method.invoke(Native Method) JS: com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) JS: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

`tns --version
2.4.0-2016-10-13-6808

This error occurs more specifically when I run array and execute an "INSERT" for each record. Has anyone had this problem before?

Thank you in advance.

Error: Module "nativescript-sqlite" not found.

I have reference the Nativescript Sqlite in my file like that var Sqlite = require( "nativescript-sqlite" );
After build from Telerik Appbuilder application loads without any issue but when live sync the changes got the error mentioned above. If I remove the Sqlite reference it works fine. Checking on android. Any help.

Uncaught TypeError: Cannot read property 'getDatabasePath' of null

I'm getting this error when I try to insert a new records. this is the code I use.

 return new Promise((resolve, reject) => {
            self.AppDB.execSQL("insert into "+self.tableName+" ("+keys.join(",")+") values ("+values.join(",")+")", [], function(err, id) {
                //console.log(err);
                if(cb != null){
                    cb().then(()=>{
                        if(err != null) reject(err);
                        else resolve(id);
                    });
                }
                else{
                    if(err != null) reject(err);
                    else resolve(id)
                }
            });
     });

I'm getting this only on Android 4.2
using NS 3.0.1
typescript 2.3.2

SQLITE.ALL - Prepare Error 1

Im receiving this error when trying to run a simple select * from query. Im assuming the database hasn't been copied properly using copyDatabase but I'm not sure why?

My database.sqlite file is in the app directory and Ive run Sqlite.copyDatabase("database.sqlite")

Could you add an error callback to Sqlite.copyDatabase?

too many sql variables

Hey every one, thanks for that great plugin, I just have that problem "too many sql variables" I'd like if there is a way to change SQLITE_MAX_VARIABLE_NUMBER.
thanks

NSFileManager.defaultManager is not a method

Hi,
I've installed the plugin but working with iOS10 (I've not tested with previous versions of the SDK) I got an error stating that defaultManager is not a function but a property of NSFileManager:

[https://developer.apple.com/reference/foundation/nsfilemanager/1855948-defaultmanager?language=objc](Objective-C definition)

The Objective-C code is
NSFileManager *fileManager = [NSFileManager defaultManager];
so it worked as a function... maybe Apple has changed something in the latest release...

Deleting the parenthesis the code works, but I think you'll have to modify the source code.

Cannot build on iOS

When I try to build on iOS I get the following:

Processing node_modules failed. Error: Command failed: /bin/sh -c ruby -e "require 'xcodeproj'; Xcodeproj::Config.new('/Users/nraboy/Desktop/SqlProject/platforms/ios/plugins-debug.xcconfig').merge(Xcodeproj::Config.new('/Users/nraboy/Desktop/SqlProject/node_modules/nativescript-sqlite/platforms/ios/build.xcconfig')).save_as(Pathname.new('/Users/nraboy/Desktop/SqlProject/platforms/ios/plugins-debug.xcconfig'))"
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- xcodeproj (LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from -e:1:in `<main>'

Seems to work fine on Android. Any ideas?

Help/Improve iOS retrieve data as object(SQLITE.RESULTSASOBJECT)

Bro, sorry my english, because this time I use Google Translate.

I'm trying to recover data from SQLite, the Object Format (db.resultType (sqlite.RESULTSASOBJECT)). In android works perfectly, but already in the iOS does not work well.
Problems encountered:
1 - file: /// app (nativescript-sqlite-example) /main-page.js:38:24: CONSOLE LOG TypeError: colName.contains is not a function. (In 'colName.contains (cn)', 'colName.contains' is undefined)
1.1 - Fixed: I added the end of the script (sqlite.ios.js), the following code:
// HERE JS
if ( !Array.prototype.contains ) {
Object.defineProperty(Array.prototype, 'contains', {
enumerable: false,
configurable: true,
writable: true,
value: function(searchElement/, fromIndex/) {
if (this === undefined || this === null) {
throw new TypeError('Cannot convert this value to object');
}
var O = Object(this);
var len = parseInt(O.length) || 0;
if (len === 0) { return false; }
var n = parseInt(arguments[1]) || 0;
if (n >= len) { return false; }
var k;
if (n >= 0) {
k = n;
} else {
k = len + n;
if (k < 0) k = 0;
}
while (k < len) {
var currentElement = O[k];
if (searchElement === currentElement ||
searchElement !== searchElement && currentElement !== currentElement
) {
return true;
}
k++;
}
return false;
}
});

}

2 - Method (_getResults) var cn = sqlite3_column_name (statement, i) .value; This not returning the column name, but the "index".
file: ///app/tns_modules/nativescript-sqlite/sqlite.js: 575: 28: CONSOLE LOG CN: 110
-- I tried to solve using other commands as sqlite3_column_origin_name, but not succeeded yet.

3 - Method (_getResult):
3.1 - I am having problem trying to retrieve a column of type text.
Note: 110 its a column "name", returned from sqlite3_column_name (statement, i) .value; the rest is "value"(text).
110: NSString {boundingRectWithSizeOptionsAttributesContext: function, cString: function, cStringLength: function, cStringUsingEncoding: function, canBeConvertedToEncoding: function, …}

3.2 - The int and float types are being returned as String, I just realized the parseInt or parseFloat, and went on to correctly return type.

I am using OSX 10.10.5, Xcode 6.4 SDK (8.4), 1.4.2 and NativeScript NativeScript-sqlite 1.0.0.

Note: I tried to https://github.com/NathanaelA/nativescript-sqlite-example, which uses NativeScript-sqlite 1.0.1 and had the same problem with iOS.

Am new development with NativeScript and javascript, I am striving to tackle this problem and help the community, please give me tips to help you and solve such problems.

For I am developing an application for company in which work and need to solve such "bugs"

In Android works fine !

Is this sqlite plugin safe for multiple inserts ... multiple readers cause issue

Hi,
Is this sqlite plugin safe for multiple inserts? I mean, I need to insert a list of records I guess one by one, so I have a for ..each adding each record and calling the exesql function, it works (seems like) but I wonder if this is safe to do.
I had an issue reading (using db.all) where I had like four consecutive lines of code calling the db.all selecting from 4 different tables and the last two result sets I was getting bad data back from the sql statement, my items have these properties [{id:1, name:'something'}] I was getting back (random issue BTW, not all times but 90% of times) [{"name":1,"undefined":"something"}], very weird issue, so I had to use chaining promises instead, so I ensure I call db.all once per query and that solved the issue, but I am not sure if the insert can potentially have the same issue.

Get method always returns null

Database on app root folder: per.sqlite
Table on it: perg
Number of rows: 5;
Nativescript 1.7

    // ... onload

    var db;
    if (!sqlite.exists("per.sqlite")) {
        sqlite.copyDatabase("per.sqlite");
    }

    new sqlite("per.sqlite", function(err, dbConnection) {
        if (!err) {
            db = dbConnection;
            db.resultType(sqlite.RESULTSASOBJECT);
            db.execSQL("SELECT * FROM perg", function(err, row) {
              console.log("Row of data was: ", JSON.stringify(row));
            });
        } else {
            console.log("db error")
        }
    });

Cannot find module 'nativescript-sqlite'

I am trying an app with "Nativescript+Typescript+NG2". Here is how my package.json dependencieslooks like -

"dependencies": { "@angular/common": "2.0.0-rc.1", "@angular/compiler": "2.0.0-rc.1", "@angular/core": "2.0.0-rc.1", "@angular/http": "2.0.0-rc.1", "@angular/platform-browser": "2.0.0-rc.1", "@angular/platform-browser-dynamic": "2.0.0-rc.1", "@angular/platform-server": "2.0.0-rc.1", "@angular/router-deprecated": "2.0.0-rc.1", "nativescript-angular": "0.1.1", "nativescript-sqlite": "^1.0.10", "tns-core-modules": "2.0.0" }

And my code looks like -

import {Sqlite} from "nativescript-sqlite";

But I am getting this error -

app/pages/actionbar/tabs/db/db.service.ts(3,22): error TS2307: Cannot find module 'nativescript-sqlite'.

I was trying on Android. Any idea why I am getting that error?

Create Table on iOS failure - SQLITE.ExecSQL Failed Prepare: 1

Hi there

Getting this error on iOS only (Android is fine)

When I try to create:

this.sqlite = new Sqlite(this.databaseName, (err, db) => {
console.log("DB");
            if (err) {
                console.log("Error: " + err);
            }

            console.log("Database opened");

            db.execSQL('create table test (`int_field` integer);', function(err) {
                if (err) {
                    console.log("!---- Create Table err", err);
                    return;
                }
            });

I am getting the error:

!---- Create Table err SQLITE.ExecSQL Failed Prepare: 1

Any ideas what this might mean?

select by column name?

Thanks for the plugin!

Is there a way to read db.all() rows results by column-name and not by index number?

Prepared Statements

Hi Nathanael

thanks for the nice plugin.
Is there a way to use prepared statements?

Nicky

DATABASE NOT CREATED SUCCESSFULLYReferenceError: Can't find variable: sqlite3_open_v2

when I am trying to run the application i am getting following error in console.

** ARCHIVE SUCCEEDED **

2017-05-03 21:23:03.369 xcodebuild[72110:1494723] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/_s/6l5z2bd97lv0wl9ztv1dmfph0000gn/T/MobileApp_2017-05-03_21-23-03.366.xcdistributionlogs'.
1.2.840.113635.100.1.61
Exported MobileApp.xcarchive to:  /Users/myUser/Desktop/MobileApp/platforms/ios/build/device
** EXPORT SUCCEEDED **

Project successfully built.
Installing...
Successfully installed on device with identifier '1f121212120a123a1aa01a12345abc1d1b1b1f1b'.
Executing before-livesync hook from  /Users/myUser/Desktop/MobileApp/hooks/before-livesync/nativescript-angular-sync.js
Transferring project files...
Skipping node_modules folder! Use the syncAllFiles option to sync files from this folder.
Successfully transferred all files.
Refreshing application...
Successfully synced application org.nativescript.MyProject on device 1f121212120a123a1aa01a12345abc1d1b1b1f1b.

Executing before-watch hook from  /Users/myUser/Desktop/MobileApp/hooks/before-watch/nativescript-dev-typescript.js
Found peer TypeScript 2.1.6
CONSOLE LOG file:///app/tns_modules/nativescript-globalevents/globalevents.js:98:16: Handler onNavigatingTo navigatingTo
CONSOLE LOG file:///app/tns_modules/@angular/core/bundles/core.umd.js:111:20: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
CONSOLE LOG file:///app/components/dbhelper/db-manager.service.js:23:36: DATABASE NOT CREATED SUCCESSFULLYReferenceError: Can't find variable: sqlite3_open_v2
9:26:21 PM - Compilation complete. Watching for file changes.

CONSOLE LOG file:///app/components/dbhelper/db-manager.service.js:23:36: DATABASE NOT CREATED SUCCESSFULLYReferenceError: Can't find variable: sqlite3_open_v2

Any help?
Thanks in advance

Can't find variable: sqlite3_open_v2

Hello,

Thanks for the plugin. This is working fine with Android but having problem with IOS.


CONSOLE ERROR file:///app/services/commonServices.js:20:30: We failed to open database ReferenceError: Can't find variable: sqlite3_open_v2
CONSOLE LOG file:///app/services/commonServices.js:21:28: null
CONSOLE ERROR file:///app/tns_modules/@angular/core/./bundles/core.umd.js:1091:24: ERROR Error: Uncaught (in promise): ReferenceError: Can't find variable: sqlite3_open_v2

What I did so far:

Delete the app off the phone.
tns platform clean ios
tns run ios

My Code:

new Sqlite("mydb.db", function(err, db) {
      if (err) {
        console.error("We failed to open database", err);

      } 

MacOS: 10.12.5 (16F73)
Xcode: Version 8.3.2 (8E2002)
NativeScript: 3.0.1

Blocking

Hi Nathan is sqlite blocking in ios and android? Thanks

Transactions not working on ios (commercial version)

Hey, I was facing a bug when trying to start transactions on iOS. Managed to fix it adding "this._transactions = [];" on line 51 to the sqlite.ios.js file.

(my package version is 1.1.5)

Decided to post here, in case it helps :)

Can't find variable: sqlite3_open_v2

Hello,

Thanks for the plugin. This is working fine with Android but having problem with IOS.


CONSOLE ERROR file:///app/services/commonServices.js:20:30: We failed to open database ReferenceError: Can't find variable: sqlite3_open_v2
CONSOLE LOG file:///app/services/commonServices.js:21:28: null
CONSOLE ERROR file:///app/tns_modules/@angular/core/./bundles/core.umd.js:1091:24: ERROR Error: Uncaught (in promise): ReferenceError: Can't find variable: sqlite3_open_v2

What I did so far:


Delete the app off the phone.
tns platform clean ios
tns run ios

My Code:

new Sqlite("sn.db", function(err, db) {
      if (err) {
        console.error("We failed to open database", err);

      } 

MacOS: 10.12.5 (16F73)
Xcode: Version 8.3.2 (8E2002)
NativeScript: 3.0.1

Run from removable/external storage

From what I can tell currently the database gets installed into a private area (internal/database storage).

Is there a way to install the database into a public storage area (ideally onto an SD Card) so that it is accessible to other users/apps?

[HELP] - Can't find variable: sqlite3_open_v2 in iOS.

Xcode Version 6.4 (SDK - 8.4)

NativeScript Version 1.4.0

We failed to open database
ReferenceError: Can't find variable: sqlite3_open_v2
message: "Can't find variable: sqlite3_open_v2"
sourceURL: "file:///app/tns_modules/nativescript-sqlite/sqlite.js"
stack: "file:///app/tns_modules/nativescript-sqlite/sqlite.js:79:40↵initializePromise@[native code]↵Promise@[native code]↵Database@file:///app/tns_modules/nativescript-sqlite/sqlite.js:71:23↵GenericDAO@file:///app/database/generic.js:7:36↵MesaService@file:///app/services/mesa-service.js:18:20↵anonymous@file:///app/services/mesa-service.js:73:33↵__executeModule↵__loadModule↵require↵anonymous@file:///app/models/mesa.js:10:26↵__executeModule↵__loadModule↵require↵anonymous@file:///app/views/mesas/index.js:3:24↵__executeModule↵__loadModule↵require↵resolvePageFromEntry@file:///app/tns_modules/ui/frame/frame-common.js:45:36↵navigate@file:///app/tns_modules/ui/frame/frame-common.js:110:40↵navigate@file:///app/tns_modules/ui/frame/frame.js:28:43↵onLoaded@file:///app/tns_modules/ui/frame/frame.js:22:26↵viewDidLoad@file:///app/tns_modules/ui/frame/frame.js:202:29↵makeKeyAndVisible@[native code]↵didFinishLaunchingWithOptions@file:///app/tns_modules/application/application.js:132:39↵[native code]↵onReceive@file:///app/tns_modules/application/application.js:55:32↵UIApplicationMain@[native code]↵start@file:///app/tns_modules/application/application.js:191:26↵anonymous@file:///app/app.js:9:18↵__executeModule↵__loadModule"

ORM compatible

First of all, many thanks for this amazing Library.

I was wondering if there's any ORM or Query Builder library that would be compatible with NativeScript SQLite such as Knex.js, Sequelize.js or node-sql

Anyone have used?

Thanks

how to handle image in iOS

I am receiving Image base64 content in Response from the Server... I am handling as below,

// assign base64 content to Imagesource
  var image = new ImageSource();
  image.loadFromBase64(getImageData[0].Image.File);

Now I would like to Implement to Store image in SQLIte
Sqlite only supports BLOB .

Base64 to BLOB file save in SQLIte

To convert base64 to BLOB i have used (NOT WORKING)

 var blob = this.b64toBlob(getImageData[0].Image.File);
 console.log("blob data: " + blob);*/

How to save and retrieve BLOB Image from Database and set to Image-Source ?

Execute multiple SQL in a transaction

Hi, thanks for providing this plugin. It's simple to use.
I would like to know how to implement transaction using this plugin, such that we can control commit/rollback when executing a batch of SQLs. Any recommendation is appreciated. Thanks.

Unable to call methods inside of the sqlite constructor calback

I am able to query the sqlite . But inside of constructor call back i am unable to call my service or component methods and Unable to access any variable that is in class. It is raising any error it just stops the execution .

getAll(){
new Sqlite("MyTable",(err, db) => {
if (err) {
console.error("We failed to open database", err);
} else {
db.all('select * from person',function(err, resultSet) {
alert("Row of data was: "+resultSet);
//Below add method is in service
this.todoStore.add("Enter Name", false,null,'','',true,null);
//
alert("working");
});
}
});
}

Can't find variable: sqlite3_open_v2

Error While Inserting Data in Sqlite for Offile line support of an Application.

Error : CONSOLE LOG file:///app/app.component.js:16:24: OPEN DB ERROR ReferenceError: Can't find variable: sqlite3_open_v2 CONSOLE LOG file:///app/app.component.js:16:24: OPEN DB ERROR ReferenceError: Can't find variable: sqlite3_open_v2 ***** Fatal JavaScript exception - application has been terminated. ***** Native stack trace: 2017-03-01 11:37:21.331984 TestOfflineApp[4727:348806] 1 0x6c12c5 NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*) 1 0x6c12c5 NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*) 2017-03-01 11:37:21.334814 TestOfflineApp[4727:348806] 2 0xb767b5 ffi_closure_inner_SYSV 2 0xb767b5 ffi_closure_inner_SYSV 2017-03-01 11:37:21.335042 TestOfflineApp[4727:348806] 3 0xb790b8 ffi_closure_SYSV 3 0xb790b8 ffi_closure_SYSV 2017-03-01 11:37:21.335722 TestOfflineApp[4727:348806] 4 0x23244fdf <redacted> 4 0x23244fdf <redacted> 2017-03-01 11:37:21.336525 TestOfflineApp[4727:348806] 5 0x230d1ee5 <redacted> 5 0x230d1ee5 <redacted> 2017-03-01 11:37:21.337501 TestOfflineApp[4727:348806] 6 0x230d1e73 <redacted> 6 0x230d1e73 <redacted> 2017-03-01 11:37:21.338277 TestOfflineApp[4727:348806] 7 0x230bbf97 <redacted> 7 0x230bbf97 <redacted> 2017-03-01 11:37:21.339047 TestOfflineApp[4727:348806] 8 0x230bc0b5 <redacted> 8 0x230bc0b5 <redacted> 2017-03-01 11:37:21.340020 TestOfflineApp[4727:348806] 9 0x230d179b <redacted> 9 0x230d179b <redacted> 2017-03-01 11:37:21.340805 TestOfflineApp[4727:348806] 10 0x230d12e7 <redacted> 10 0x230d12e7 <redacted> 2017-03-01 11:37:21.341572 TestOfflineApp[4727:348806] 11 0x230cbee7 <redacted> 11 0x230cbee7 <redacted> 2017-03-01 11:37:21.342339 TestOfflineApp[4727:348806] 12 0x2309ccf5 <redacted> 12 0x2309ccf5 <redacted> 2017-03-01 11:37:21.343149 TestOfflineApp[4727:348806] 13 0x2383898d <redacted> 13 0x2383898d <redacted> 2017-03-01 11:37:21.344624 TestOfflineApp[4727:348806] 14 0x238325d3 <redacted> 14 0x238325d3 <redacted> 2017-03-01 11:37:21.344882 TestOfflineApp[4727:348806] 15 0x1dfac71b <redacted> 15 0x1dfac71b <redacted> 2017-03-01 11:37:21.345052 TestOfflineApp[4727:348806] 16 0x1dfac225 <redacted> 16 0x1dfac225 <redacted> 2017-03-01 11:37:21.345438 TestOfflineApp[4727:348806] 17 0x1dfaa4fb <redacted> 17 0x1dfaa4fb <redacted> 2017-03-01 11:37:21.345594 TestOfflineApp[4727:348806] 18 0x1def9533 CFRunLoopRunSpecific 18 0x1def9533 CFRunLoopRunSpecific 2017-03-01 11:37:21.345741 TestOfflineApp[4727:348806] 19 0x1def9341 CFRunLoopRunInMode 19 0x1def9341 CFRunLoopRunInMode 2017-03-01 11:37:21.346011 TestOfflineApp[4727:348806] 20 0x1f6d0bfd GSEventRunModal 20 0x1f6d0bfd GSEventRunModal 2017-03-01 11:37:21.346866 TestOfflineApp[4727:348806] 21 0x23107e27 <redacted> 21 0x23107e27 <redacted> 2017-03-01 11:37:21.347940 TestOfflineApp[4727:348806] 22 0x23102551 UIApplicationMain 22 0x23102551 UIApplicationMain 2017-03-01 11:37:21.348397 TestOfflineApp[4727:348806] 23 0xb7902c ffi_call_SYSV 23 0xb7902c ffi_call_SYSV 2017-03-01 11:37:21.348618 TestOfflineApp[4727:348806] 24 0xb764f9 ffi_call 24 0xb764f9 ffi_call 2017-03-01 11:37:21.349054 TestOfflineApp[4727:348806] 25 0x68d397 NativeScript::FFICall::call(JSC::ExecState*) 25 0x68d397 NativeScript::FFICall::call(JSC::ExecState*) 2017-03-01 11:37:21.352421 TestOfflineApp[4727:348806] 26 0x95a40f JSC::LLInt::setUpCall(JSC::ExecState*, JSC::Instruction*, JSC::CodeSpecializationKind, JSC::JSValue, JSC::LLIntCallLinkInfo*) 26 0x95a40f JSC::LLInt::setUpCall(JSC::ExecState*, JSC::Instruction*, JSC::CodeSpecializationKind, JSC::JSValue, JSC::LLIntCallLinkInfo*) 2017-03-01 11:37:21.352993 TestOfflineApp[4727:348806] 27 0x959e8b llint_slow_path_call 27 0x959e8b llint_slow_path_call 2017-03-01 11:37:21.353407 TestOfflineApp[4727:348806] 28 0x9615ab llint_entry 28 0x9615ab llint_entry 2017-03-01 11:37:21.353790 TestOfflineApp[4727:348806] 29 0x9615b7 llint_entry 29 0x9615b7 llint_entry 2017-03-01 11:37:21.354783 TestOfflineApp[4727:348806] 30 0x9615b7 llint_entry 30 0x9615b7 llint_entry 2017-03-01 11:37:21.355173 TestOfflineApp[4727:348806] 31 0x9615b7 llint_entry 31 0x9615b7 llint_entry JavaScript stack trace: 1 _rethrowWithContext@file:///app/tns_modules/@angular/core/bundles/core.umd.js:12760:77 2 @file:///app/tns_modules/@angular/core/bundles/core.umd.js:12777:46 3 @[native code] 4 @file:///app/tns_modules/nativescript-angular/renderer.js:213:31 5 invoke@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:190:33 6 onInvoke@file:///app/tns_modules/@angular/core/bundles/core.umd.js:4391:47 7 invoke@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:189:42 8 run@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:83:49 9 zonedCallback@file:///app/tns_modules/nativescript-angular/renderer.js:212:27 10 notify@file:///app/tns_modules/tns-core-modules/data/observable/observable.js:149:31 11 _emit@file:///app/tns_modules/tns-core-modules/data/observable/observable.js:168:24 12 _raiseTap@file:///app/tns_modules/tns-core-modules/ui/action-bar/action-bar-common.js:318:19 13 tap@file:///app/tns_modules/tns-core-modules/ui/action-bar/action-bar.js:248:28 14 UIApplicationMain@[native code] 15 start@file:///app/tns_modules/tns-core-modules/application/application.js:251:26 16 bootstrapApp@file:///app/tns_modules/nativescript-angular/platform-common.js:68:28 17 bootstrapModule@file:///app/tns_modules/nativescript-angular/platform-common.js:56:26 18 anonymous@file:///app/main.js:5:57 19 evaluate@[native code] 20 moduleEvaluation@[native code] 21 @[native code] 22 promiseReactionJob@[native code] JavaScript error: 2017-03-01 11:37:21.358255 TestOfflineApp[4727:348806] file:///app/tns_modules/@angular/core/bundles/core.umd.js:12760:77: JS ERROR Error: Error in app.component.html:1:4 caused by: undefined is not an object (evaluating 'this.database.execSQL') file:///app/tns_modules/@angular/core/bundles/core.umd.js:12760:77: JS ERROR Error: Error in app.component.html:1:4 caused by: undefined is not an object (evaluating 'this.database.execSQL')

Please find attached Sample Program code.
sample.zip

Environment: node v6.9.2, Xcode 8.2.1, CLI 2.5.2, cocoa pods : 1.2.0

sqlite.copyDatabase()

Hi,
As per the documentation I have my testdb.db file inside the app folder. and when I am trying to execute the code sqlite.copyDatabase('testdb.db') it throws error.
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.groceries/com.tns.NativeScriptActivity}: com.tns.NativeScriptException:
Calling js method getActivity failed

Error:
Error calling module function

Error: java.io.FileNotFoundException: app/testdb.db
android.content.res.AssetManager.openAsset(Native Method)
android.content.res.AssetManager.open(AssetManager.java:316)
android.content.res.AssetManager.open(AssetManager.java:290)
com.tns.NativeScriptActivity.getMethodOverrides(Native Method)
com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:1567)
android.app.Activity.performCreate(Activity.java:5133)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
android.app.ActivityThread.access$600(ActivityThread.java:141)
android.app.ActivityThread$H.handleM

image

can any one please help me.
May be I misunderstood the concept of copyingDatabase

Thanks In Advance

Sqlite.version throws an error when called without arguments

When used without a callback to get a Promise, the function throws an error. In Android the error is:

Error: java.lang.IllegalArgumentException: Cannot bind argument at index 1 because the index is out of range. The statement has 0 parameters..

Presumably iOS has a similar error. This error is coming from Sqlite.get:

cursor = self._db.rawQuery(sql, self._toStringArray(params));

The reason is that Sqlite.version, when called without arguments, calls Sqlite.get with the mode flag in the params argument:

return this.get('PRAGMA user_version', Database.RESULTSASARRAY);

Which Sqlite.get fails to handle correctly.

Cannot build/run/emulate on iOS

If I try to run the build for an Android platform, there are no issues and all functionality is present. However, if I try to run on any iOS device I receive the following error:

john-thornewills-imac:nextra-test johnt$ tns emulate ios
Successfully prepared plugin nativescript-insomnia for ios.
Successfully prepared plugin nativescript-sqlite for ios.
Processing node_modules failed. Error: Command failed: /bin/sh -c ruby -e "require 'xcodeproj'; Xcodeproj::Config.new('/Users/johnt/Dropbox/NativeScript/nextra-test/platforms/ios/plugins-debug.xcconfig').merge(Xcodeproj::Config.new('/Users/johnt/Dropbox/NativeScript/nextra-test/node_modules/nativescript-sqlite/platforms/ios/build.xcconfig')).save_as(Pathname.new('/Users/johnt/Dropbox/NativeScript/nextra-test/platforms/ios/plugins-debug.xcconfig'))"
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- xcodeproj (LoadError) from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from -e:1:in `

'

Any ideas folks?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.