PDA

View Full Version : SqliteProxy for ST2



tomalex0
19 Oct 2011, 1:57 AM
Hi,

I have ported sqliteproxy to work with ST2.

You can find previous thread
http://www.sencha.com/forum/showthread.php?146465-SqliteProxy&p=661960

U[/URL]pdated Code can be found under .
[URL]https://github.com/tomalex0/SenchaTouch-v2-SqliteProxy (http://www.sencha.com/forum/showthread.php?146465-SqliteProxy&p=661960)

diesalher
12 Dec 2011, 9:44 AM
Hi.

I'm a bit new in sencha and javascript so maybe this makes no sense...

i've modified your proxy to be able to use params in the query..




read: function(operation, callback, scope) {
var me = this;


var sql = me.dbConfig.dbQuery || 'SELECT * FROM ' + me.dbConfig.tablename + '';
var params, onSucess, onError;


params = me.dbConfig.params ? me.dbConfig.params : [];


onSucess = function(tx, results) {
me.applyDataToModel(tx, results, operation, callback, scope);
};


onError = function(tx, err) {
me.throwDbError(tx, err);
};


me.queryDB(me.dbConfig.dbConn, sql, onSucess, onError, params);
}



then, in order to load the store i do somethig like...




var qry = 'SELECT * FROM Test where field 1 = ? and field2 = ?';
var params = [ 'P1','P2'];

store.getProxy().dbConfig.dbQuery = qry;
store.getProxy().dbConfig.params = params;
store.load();



Maybe what i say makes no sense for some reason i dont know...but it seems to work.

tomalex0
12 Dec 2011, 8:48 PM
@diesalher

Yea its fine, there are couple of other ways also, so i haven't rounded upon one :).



read: function(operation, callback, scope) {

var param_arr = [];
Ext.iterate(operation.params,function(a,i){
param_arr.push(i);
});

var thisProxy = this;
var sql = operation.query || thisProxy.dbConfig.dbQuery || 'SELECT * FROM '+thisProxy.dbConfig.tablename+'';

var params, onSucess, onError;

onSucess = function(tx, results) {
thisProxy.applyDataToModel(tx, results, operation, callback, scope);
};


onError = function(tx, err) {
thisProxy.throwDbError(tx, err);
};



thisProxy.queryDB(thisProxy.dbConfig.dbConn, sql, onSucess, onError,param_arr);
}


Example



contactStore.load({params :{ name: '435'},query : 'select * from contacts_tables WHERE firstName = ?'});

sarah_77
3 Jan 2012, 7:14 AM
Great!! But this is a solution for manage SQLLite on PhoneGap with Sencha Touch 2.0?

Thanks

diesalher
3 Jan 2012, 7:40 AM
I've been using sqliteproxy with good results in sencha 2.0

i have a question

I'm doing a function who loads data in several tables . Is there a way to do this inserts in a batch to load the stores when in finish the complete batch?

now, to insert a record im doing something like..


Ext.create(model, {field1: data1,field2: data2}).save();

but it seems to be asynchronous so if i insert 1000 records, i don't know if there is a way to wait till inserted to do a store.load() again.

Maybe i'm facing this in the wrong way, i'm still learning javascript and sencha,

Thanks

sarah_77
4 Jan 2012, 10:36 AM
I don't know this point: this is a solution for manage SQLLite on PhoneGap with Sencha Touch 2.0?

Thanks

diesalher
5 Jan 2012, 12:20 AM
I don't know this point: this is a solution for manage SQLLite on PhoneGap with Sencha Touch 2.0?
Thanks

This is a proxy which uses the sqlite web sql database of the browser as backend for Sencha touch. Works with Phonegap or without it. The Author can give you more details, as i'm pretty new using it, but basically i'm using to store my app data in sqlite database.

sarah_77
6 Jan 2012, 2:15 AM
Great! So this is SQLLite solution that don't use HTML5 localstorage! It uses SQLLite way....Right?

Thanks

tomalex0
6 Jan 2012, 2:38 AM
Sqlite query operation in browsers are asynchronous in nature, So i'm not sure how to handle callback of batch insertion. But you can implement callback in save function

Go through http://docs.sencha.com/touch/2-0/#!/api/Ext.data.Model which does have usage of success callback in save function



user.save({success: function() {console.log('The User was updated');}});




I've been using sqliteproxy with good results in sencha 2.0

i have a question

I'm doing a function who loads data in several tables . Is there a way to do this inserts in a batch to load the stores when in finish the complete batch?

now, to insert a record im doing something like..


Ext.create(model, {field1: data1,field2: data2}).save();

but it seems to be asynchronous so if i insert 1000 records, i don't know if there is a way to wait till inserted to do a store.load() again.

Maybe i'm facing this in the wrong way, i'm still learning javascript and sencha,

Thanks

tomalex0
6 Jan 2012, 2:39 AM
Yes it is using Sqlite Storage

Great! So this is SQLLite solution that don't use HTML5 localstorage! It uses SQLLite way....Right?

Thanks

sarah_77
7 Jan 2012, 7:03 AM
Great!! Thanks for your reply!

Can you tell me differences between

HTML5 local storage
SQL Lite
webssql


I try, please check if what I wrote is OK!

HTML5 local storage: 5mb limit, not real DB
SQL Lite: no DB limit, MySQL Lite DB, integrated with PhoneGap (from PhoneGap I can manage all storage created and managed using Sencha Touch 2)
webssql: ??

Thanks

diesalher
26 Jan 2012, 7:26 AM
It seems Sqliteproxy is not working wirh Sencha Touch 2 latest release (pr4) with MVC, are you planning an upgrade?

EDIT: One of the problems is that dbConfig is now into config object of the proxy.

tomalex0
26 Jan 2012, 9:25 AM
Yea there are some issues :(. I will look into it

diesalher
26 Jan 2012, 10:10 AM
Thanks!

sarah_77
30 Jan 2012, 5:37 AM
Is there a release date for Sqllite Proxy fix? (make it working on PR4)

Thanks

tomalex0
30 Jan 2012, 4:21 PM
There are some annoying issue which i'm facing and i'm still looking into. But for now i have almost done read and create section. I will update github once it is completed

sarah_77
2 Feb 2012, 2:58 AM
Hi! When do you think to resolve Sqlite Proxy problems for make it working on B1?

Thanks

sarah_77
4 Feb 2012, 9:17 AM
is it plugin working on Beta1?

Thanks

diesalher
14 Feb 2012, 1:08 AM
In the previous Sqliteproxy, when u loaded a store with custom sql, (which contains custom fields that were not in the model of the store) the store loaded with the custom fields at the end. Now with the new version, only the fields in the model are loaded.

This was a useful feature before, is possible to recover it in this version?

anhnt3
27 Feb 2012, 8:58 PM
Hi there,

sqliteproxy work well with Chrom but when I make deploy sqliteproxy to android machine with phonegap, it faield. There is a javascript TypeError exception in every [me.config.dbConfig.dbConn.transaction] in SqliteProxy.js.

So i have to add these line to construct of SqliteProxy to init dbConn again. I do not know why but it worked :-? -> please review this solution for me. Thanks



constructor: function(config) {
this.callParent([config]);


//ensures that the reader has been instantiated properly
this.setReader(this.reader);
var me = this;
me.config.dbConfig.dbConn = openDatabase(me.config.dbConfig.dbName,
me.config.dbConfig.dbVersion,
me.config.dbConfig.dbDescription,
me.config.dbConfig.dbSize);
me.createTable();
},

ThisIsCool
2 Mar 2012, 8:17 PM
Hello

I tried the SqliteProxy , both ST1 & ST2.

ST1 runs perfect, really nice, just what I'm looking for, thank you very much.

But when running the demo for the ST2 version, I got Type Error, on SqliteProxy.js 137.

I'm using the ST2 RC, is SqliteProxy v2 broken under this ST2 RC?

Thank you very much.

tomalex0
2 Mar 2012, 9:34 PM
Hi All,

I was quite busy with my works, i'm working on this proxy compatible for STRC2, there were some roadblocks while porting. Hopefully i can finish it in couple of days. But i'm not sure how good it gonna work.

One limitation as of for now is
if we have table field name as "id" which is a primary key, we will have to mention a dummy name(not a field in table) as idProperty of model and clientIdProperty as "id". The issue is that default idProperty of model is "id" which will always have value like this "ext-record-x". If mentioned config options are not specified in model, id value in table will be like ext-record-1,2,3. But we expect it as integer.

http://docs.sencha.com/touch/2-0/source/Model.html#Ext-data-Model look for setId this actual adds idProperty("id") to model even if we are not specifying id as field option.

I'm looking into possibility to avoid this config dependency.

ThisIsCool
4 Mar 2012, 7:27 PM
Hi tomalex

Thank you for your reply. Looking forward to your update.

For now as a temporary fix, I used what anhnt3 posted, to init dbConn again, and somehow got it to work.:-?

Thanks.

tomalex0
4 Mar 2012, 8:08 PM
Hi

I have updated github with latest change, please have a look

MauiRa
8 Mar 2012, 2:24 PM
When I run your sample app in Safari 5.1.2, which is what the latest IOS uses, I get this error:

TypeError: Type error SqliteProxy.js:128

Here is where it errors:

The native code seems to reject the callback function. This works in this browser with Sencha Touch 1.1.

me.dbConfig.dbConn.transaction(function(tx) {

var onError = function(tx, err) {
me.throwDbError(tx, err);
};

var onSucess = function(tx, results) {
console.log("success");
}

var createTable = function() {
var createsql = 'CREATE TABLE IF NOT EXISTS ' + me.dbConfig.tablename + '('+me.constructFields()+')';
tx.executeSql(createsql,[],onSucess,onError);
}
var tablesql = 'SELECT * FROM '+ me.dbConfig.tablename+' LIMIT 1';
tx.executeSql(tablesql,[], Ext.emptyFn, createTable);
});file:///C:/Program%20Files%20(x86)/Common%20Files/Apple/Apple%20Application%20Support/WebKit.resources/inspector/Images/errorIcon.pngSqliteProxy.js:128TypeError: Type error

die_for_rock_vn
10 Mar 2012, 4:59 AM
Does anyone try Sqlite proxy + phonegap 1.5 in iOS? I make it works in android but doesn't work in iOS.

tomalex0
10 Mar 2012, 6:49 AM
Hi
I have looked into the issue with proxy not working in safari 5, somehow the reference to database object in safari is changed, Can anyone test sqliteproxy in safari 4 ?


If you look into below two images, where ""Reference" is database object passed with model
and "Freshly Created" is new database created using openDatabase function inside the proxy . Comparing both objects its seen that the passed database config is considered only as a simple object in safari 5, but it should be a database object.


I'm not sure where it is going wrong,

Safari
32593


Chrome
32594

tomalex0
10 Mar 2012, 10:19 AM
Hi,
Please get latest code from github, issue related to safari is fixed.

die_for_rock_vn
11 Mar 2012, 8:37 PM
working in safari and iOS with Phonegap.
Best regards.

MauiRa
12 Mar 2012, 6:54 PM
It works perfectly with Safari 5.X now. Thanks for your quick solution!

Mika83AC
13 Mar 2012, 3:16 AM
Hello!

How is it possible to connect to an existing sqlite db in the folder of the app? All my trys just resulted in an sqlite db created in the isolated storage of the browser, but it seem's not to be possible to connect to an existing sqlite db in the file system.

Where is my mistake ? :)

Regards,
Michael

tomalex0
13 Mar 2012, 8:43 AM
This maybe helpful

https://github.com/davibe/Phonegap-SQLitePlugin

MauiRa
13 Mar 2012, 1:20 PM
Hello!

How is it possible to connect to an existing sqlite db in the folder of the app? All my trys just resulted in an sqlite db created in the isolated storage of the browser, but it seem's not to be possible to connect to an existing sqlite db in the file system.

Where is my mistake ? :)

Regards,
Michael

Is this on Android or on IOS?

For Android, phonegap already has a way of using an external data source you simply must use it instead of the generic window.openDatabase.

Here is what I have done:

phonegap.1.4.1.js defines a DroidDB_opendatabase which can be used in place of the browsers implementation.

In SQLConnection, I do this:

Ext.ns('Ext.Sqlite');


Ext.Sqlite.Connection = Ext.define('Ext.Sqlite.Connection', {
extend: 'Ext.util.Observable',
/**
* @cfg {String} dbName
* Name of database
*/
dbName: undefined,

/**
* @cfg {String} version
* database version. If different than current, use updatedb event to update database
*/
dbVersion: '1.19',

/**
* @cfg {String} dbDescription
* Description of the database
*/
dbDescription: '',

/**
* @cfg {String} dbSize
* Max storage size in bytes
*/
dbSize: 5 * 1024 * 1024,

/**
* @cfg {String} dbConn
* database connection object
*/
dbConn : undefined,

constructor : function(config) {
config = config || {};

Ext.apply(this, config);
var me = this;

me.callParent([this]);
if(navigator.userAgent.toLowerCase().match(/android/)){
window.droiddb = new DroidDB();
me.dbConn = DroidDB_openDatabase(me.dbName, me.dbVersion, me.dbDescription, me.dbSize);
} else {
me.dbConn = openDatabase(me.dbName, me.dbVersion, me.dbDescription, me.dbSize);
}
return me;
}
});

This uses the dbname in the app namespace /data/data/app.package.name/app_database:appname.db which is the default path used by Storage.java -> openOrCreateDatabase.

Perhaps the same can be done for IOS with a SQLite plugin.

My team is currently implementing davibe's plugin for IOS so that a second conditional may be used:

if(navigator.userAgent.toLowerCase().match(/android/)){
window.droiddb = new DroidDB();
me.dbConn = DroidDB_openDatabase(me.dbName, me.dbVersion, me.dbDescription, me.dbSize);
} else if (navigator.userAgent.toLowerCase().match(/ios/)){
me.dbConn =PGSQLite_openDatabase(me.dbName, me.dbVersion, me.dbDescription, me.dbSize);
} else{
me.dbConn = openDatabase(me.dbName, me.dbVersion, me.dbDescription, me.dbSize);
}

tomalex0
13 Mar 2012, 5:44 PM
Thanks for the info regarding android sqlite plugin,

Is that working fine ?, do let me know how ios phonegap works ?, we can include some config option in current proxy to prefer type of DB.

shepsii
15 Mar 2012, 5:45 AM
Being a nitpicker here as this work is great and looking forward to sticking my teeth into it - but could the classes be renamed so they work better with the loader? For the time being I have put the two files at:

sdk/src/data/proxy/SqliteStorage.js, and
sdk/src/sqlite/Connection.js

So their paths match their class names - a small issue but makes it easier for people using the proxy for the first time!

tomalex0
15 Mar 2012, 8:33 PM
Being a nitpicker here as this work is great and looking forward to sticking my teeth into it - but could the classes be renamed so they work better with the loader? For the time being I have put the two files at:

sdk/src/data/proxy/SqliteStorage.js, and
sdk/src/sqlite/Connection.js

So their paths match their class names - a small issue but makes it easier for people using the proxy for the first time!

I haven't considered the loader scenario :D, thanks for the suggestions, this will be helpful for many others.

shepsii
16 Mar 2012, 1:02 AM
Hey Tom,

Thanks again for this work, I can't tell you how useful it is to my project which really needs more than localstorage can provide. Saving me so much time!

I just had a couple more suggestions for you, changes I've made to the SqliteStorage.js file, that again others might find useful.

I put a debug config on the class and when this is set to false, no errors are logged to the console; useful when you trust that the proxy is doing what it should and want to debug other areas of your project without the console being swamped!

I also had a case where I was trying to use a callback on record.save() to then use the record's id as a foreign key in another db table. The issue I ran into was that the operation of the create method on the Ext.data.proxy.SqliteStorage class sets the operation to completed and successful when the query has been sent to the db connection; not when the query has been successfully executed. Therefore, record.get('id'); as in the code below was returning undefined:



record.save(function() {
record.get('id');
});


I put a workaround into the proxy that may be a bit hacky but it works; basically I added a callback to the setRecord function, and then inside the for loop of the create function I used this callback to count completed records. When completed records equals records.length, then I set the operation to completed and successful, and execute the callback to the create function. This works for me but may not be the best way of doing it!

Thanks again for all the hard work, invaluable for those looking to leverage the advantages Sqlite can get them in ST2, particularly important with how awkward localstorage can be with ST2.

daveik
18 Mar 2012, 1:53 PM
I'm trying to get it running with the loader. I'm now stuck with this error message:



Cannot read property 'dbConn' of undefined SqliteStorage.js:120

Does anybody has a clue? I'm new to Sencha. Sorry. :(

daveik
18 Mar 2012, 2:12 PM
found the problem. DBConnection need to be defined before the stores and models. I got the hint from here: http://www.sencha.com/forum/showthread.php?146465-SqliteProxy/page3

thanks

nsicad
20 Mar 2012, 3:20 PM
Hi,

(Edited).

My mistake, the github has already the demo example.

I need just to figure out how to work this demo in PhoneGap.

Thanks.

Noli

gcw07
21 Mar 2012, 7:31 AM
I'm trying to set this up using the newer Ext.application method of creating the app instead of the onReady way you have in the demo. I'm able to get it partly working, but I can't figure out how to get rid of a warning. At first I tried having everything within the Ext.application, but that caused errors with the stores because it was loading them up before the database was initiated. So I moved the database connection outside of the Ext.application.



//<debug>
Ext.Loader.setPath({
'Ext': 'sdk/src',
'Ext.Sqlite.Connection': 'lib/SqliteConnection.js',
'Ext.data.proxy.SqliteStorage': 'lib/SqliteProxy.js'
});
//</debug>

Ext.ClassManager.setAlias('Ext.data.proxy.SqliteStorage', 'proxy.sqlitestorage');
Ext.namespace('DbConnection');

// Setup the database
var dbconnval = {
dbName: 'testapp',
dbDescription: 'Test App Database',
dbVersion: '1.00',
};

// Has no effect on the warning
//Ext.require(['Ext.Sqlite.Connection','Ext.data.proxy.SqliteStorage']);

// Create database connection
Ext.DbConnection = Ext.create('Ext.Sqlite.Connection', dbconnval); // line that is causing the warning

Ext.application({
....
and the warning I keep getting:

[WARN] [Ext.Loader] Synchronously loading 'Ext.Sqlite.Connection'; consider adding 'Ext.Sqlite.Connection' explicitly as a require of the corresponding class

Any help in figuring this out or even narrowing it down with be greatly appreciated. Thanks.

daveik
22 Mar 2012, 6:15 AM
I was trying to get it running with the ST native wrapper. Unfortunately, without any success. It works fine with phonegap, though.

eeldwin
28 Mar 2012, 5:46 PM
I used sencha 2.0 (commercial release) and phonegap 1.4.1 to run the demo for SQLiteProxy. The interface is appeared fine on the emulator, but it can't add new user and list the existing user.

Tried to debug add user functionality, just found out that the form, validation, and data input were fine, until it reach setRecord function

console.log(record.getData().id,"recprd2");

The record.getData().id will return null value.

Anyone experienced this problem?

Whitejoker
30 Mar 2012, 3:34 AM
Is it possible to use associations with this proxy? If so do you have an example on how to use these?

roycyang
3 Apr 2012, 8:12 PM
I read though this and saw that this question wasn't fully answered (I think).

Is this websql or SQLite? The reason I'm asking is because I've been hearing that iOS 5.1 can randomly delete our local storage and websql data. I'm now looking for SQLite only solutions that won't be deleted.

I'm planning on running iOS 5.1 with phonegap 1.5 (why oh why did they rename it Cordova? (stupid adobe) and I think the current phonegap SQLite plugin is only available for PG1.3 and I'm looking for a sencha solution for the sake of my sanity while I develop and error test.

eeldwin
3 Apr 2012, 10:14 PM
I read though this and saw that this question wasn't fully answered (I think).

Is this websql or SQLite? The reason I'm asking is because I've been hearing that iOS 5.1 can randomly delete our local storage and websql data. I'm now looking for SQLite only solutions that won't be deleted.

I'm planning on running iOS 5.1 with phonegap 1.5 (why oh why did they rename it Cordova? (stupid adobe) and I think the current phonegap SQLite plugin is only available for PG1.3 and I'm looking for a sencha solution for the sake of my sanity while I develop and error test.

just found out that this proxy doesn't work for ios 5.1, but work perfectly for 5.0

alohainc
9 Apr 2012, 7:26 AM
Hi following is my code,



var sampleStore = Ext.data.StoreManager.get('sampleStore');
sampleStore.load({ params: { }, query: 'SELECT Name, Desc FROM SampleTable WHERE ID = (SELECT MAX(ID) FROM SampleTable' });


here simply I am trying to get the last row of data in store in controller file, but it is giving all the rows. Please help.

MauiRa
4 May 2012, 5:55 PM
This is the source for a native SQLite plugin within IOS and a .js file for that plugin.

Herein also lies a SQLiteConnection.js file that open a native connection for either Android or IOS while opening a webdata connection for pure web browsers.

There are many examples in previous posts on loading the js files.

Make sure the phonegap1.4.1.js file is first loaded, then the pgsqlite_plugin.js for IOS and the SQLiteConnection.js after the two.

Android already has a native sqlite 3 implementation with storage and the SQLiteConnection.js makes use of the DroidDB_openDatabase function to the native code.

Under <key>Plugins</key> in the PhoneGap.plist, add this key value pair:

<key>PGSQLitePlugin</key>
<string>PGSQLitePlugin</string>

10 May 2012, 1:40 AM
Hi,
Can somebody please help me to get the solution
Is there any way to save multiple records at a time to a sqlite table .
I am trying in the following way..

The model structure is like


Ext.define("WorkOrder", {
extend: "Ext.data.Model",

config : {
idProperty : 'uniqueid', // if we have field with name as id, conflicts happens with default idProperty(id) which always have value as ext-record-x
clientIdProperty : 'Id',
fields: [{
name: 'Id',
type: 'string',
fieldOption: 'PRIMARY KEY'
}, {
name: 'Name',
type: 'string'
},{
name: 'CreatedDate',
type: 'string'

}],
proxy: {
type: 'sqlitestorage',
dbConfig: {
tablename: 'WorkOrder',
dbConn: Ext.DbConnection
},
reader: {
type: 'array'
}
}
},
writer: {
type: 'array'
}
});




I want read the data from json file put all the data to the table(WorkOrder).
The .json file


{


"records":[
{
"attributes":{
"type":"Account",
"url":"/services/data/v22.0/sobjects/Account/0019000000556qrAAA"
},
"Id":"0019000000556qrAAA",
"Name":"Sameer Roy1",
"CreatedDate":"2011-03-22T04:56:15.000+0000"
},
{
"attributes":{
"type":"Account",
"url":"/services/data/v22.0/sobjects/Account/0019000000A9xaBAAR"
},
"Id":"0019000000A9xaBAAR",
"Name":"MR.Jone",
"CreatedDate":"2012-03-07T06:32:56.000+0000"
},
{
"attributes":{
"type":"Account",
"url":"/services/data/v22.0/sobjects/Account/00190000006JHSJAA4"
},
"Id":"00190000006JHSJAA4",
"Name":"GenePoint",
"CreatedDate":"2011-03-03T12:57:09.000+0000"
}
]
}





This is way i have tried to insert into table,



var recordArray = [];
for( i in records ) { //records are the json result object
record = records[i] ;
var recordObj={ //Here tried to create a object of key /value
Id: record['Id'],
Name:record['Name'],
CreatedDate:record['CreatedDate']
}
recordArray.push(recordObj);
}
console.log('recordArray[0]##################################'+recordArray);
var rec = Ext.create('WorkOrder', recordArray).save();



The following giving the result by inserting [object Object] to all columns.If am not using the recordArray instead inserting the recordObj,then its only inserting the last value of the json result.

How I can insert all the values in json file to the table?????????
Thanks in advance...

shepsii
10 May 2012, 1:59 AM
So I think your task would be easier with the more advanced proxy found here:
http://www.sencha.com/forum/showthread.php?195991-SQLite-Proxy-for-ST2-(advanced)

I (http://www.sencha.com/forum/showthread.php?195991-SQLite-Proxy-for-ST2-(advanced))t is more advanced, and therefore what you need to do is simpler.

Notice you'll need to change the fields of your model a little, build it out from the example included.

Regardless of which proxy you use, you want to do something like this:

1. Load in data using a json proxied store
2. Iterate through loaded data (after it has been loaded) and copy each record.
3. Add copy of record to new store using a sqlite proxy
4. Set these new copies to be a phantom (just record.phantom = true does the job)
5. Sync the new store.

The reason I suggest using the advanced proxy, is that it will group all the insert queries into one database transaction, which will be quicker, and the operation will only be marked as finished when the transaction has completed. This means that you can listen to the write event of the store, for instance, and act there knowing the data has been inserted.

Your approach at the moment suffers because the fields on your model are more complicated than they need to be, and the way you're copying the records now means that if you change the fields, you have to go and change the copy record code too which isn't ideal.

Also, I can't remember if the sqlite proxy of this thread is compatible with the date type, but the advanced proxy is, so if you used that you could change the createdDate field to have date type, which semantically would make much more sense.

JacobGu
23 May 2012, 12:17 PM
I took the code, and tweaked it to support ST1. It doesn't seem that the implementation supports an 'id' field which is set independently (e.g., such as a server). Is that supported under ST2? If I try to set it up that way on ST1, the server id's do get written to sql properly, but the getInsertRecordFunc and getUpdateRecordFunc overwrite the id in memory to the rowid. So now there is no reference to the server id. But if I re-read the data from sql, it will set the id properly, since applyDataToModel calls 'new Model(data, rowid)', which will set the id to the server id and internalId to rowid.

UPDATE ON MY QUESTION ABOVE: I just came across the following thread post which answers the question - http://www.sencha.com/forum/showthread.php?195991-SQLite-Proxy-for-ST2-(advanced)&p=805349&viewfull=1#post805349. Basically, the id field is "reserved" to store rowid, and a server record id should use a different name. It would certainly be nice if the proxy could be smart enough to allow developer use of id and use a different mechanism to track rowid.

24 May 2012, 2:54 AM
Thanks for reply.:)

pushm0v
28 May 2012, 10:38 PM
i want to say this is GREAT work, but i have encounter a problem, do you have any idea if this proxy can be use with list paging? i have tried , but none of them works, it always display all record or some record that come with "LIMIT X",



var p = store.getProxy();
p.queryDB(p.getDb(), 'SELECT * FROM master_site WHERE condition = \'' +my_condition + '\' ;',querySuccess);

store.load();


on my view :


{
xtype: 'list',
id: 'siteList',
ui: 'round',
store: store,
plugins: [
{
xclass: 'Ext.plugin.ListPaging',
autoPaging: true
}
]
}


any help will be greatly appreciated :) thx

shepsii
7 Jun 2012, 8:33 AM
This proxy supports paging:

http://www.sencha.com/forum/showthread.php?195991-SQLite-Proxy-for-ST2-(advanced)

mobileDev1600
1 Mar 2013, 6:24 AM
Hi tomalex,

Just wondering if your proxy is good for app which is based on PhoneGap + ST2 and SQlite database (not web sql).
I have a SQLite database with some values added and want to use it in my app which i am creating using PhoneGap 2.3 and ST2.

Thank you


Hi,

I have ported sqliteproxy to work with ST2.

You can find previous thread
http://www.sencha.com/forum/showthread.php?146465-SqliteProxy&p=661960

Updated Code can be found under .
https://github.com/tomalex0/SenchaTouch-v2-SqliteProxy

vadimv
3 Mar 2013, 12:35 AM
@mobileDev1600 , ST2 has its own proxy for SQLite databases, check the docs and here http://vadimpopa.com/sencha-touch-2-sql-proxy-for-sqlite/