SlideShare a Scribd company logo
1 of 19
Download to read offline
SQLite &
                            Titanium
                             Who, How & Where




          #TiLon                                London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
About

                            Ketan Majmudar

                            @ketan (twitter)

                            spiritquest.co.uk

                            stereoartist.com

                            freakshowuk.com




          #TiLon                                        London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
What is SQLite
           SQLite is a software library that
             implements a self-contained,
      serverless,zero-configuration, transactional
                 SQL database engine.



                 Serverless

                 Open Source

                 Compact




          #TiLon                                    London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
What is SQLite
           SQLite is a software library that
             implements a self-contained,             SQLite is an embedded SQL
      serverless,zero-configuration, transactional    database engine. Unlike most
                 SQL database engine.                 other SQL databases, SQLite
                                                    does not have a separate server
                                                    process. SQLite reads and writes
                 Serverless                          directly to ordinary disk files.

                 Open Source

                 Compact




          #TiLon                                                  London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
What is SQLite
           SQLite is a software library that
             implements a self-contained,
      serverless,zero-configuration, transactional
                 SQL database engine.
                                                       The code for SQLite is in the
                                                     public domain and is thus free
                 Serverless                              for use for any purpose,
                                                    commercial or private. SQLite is
                 Open Source                             currently found in more
                                                     applications than we can count
                 Compact                              including several high-profile
                                                                  projects.




          #TiLon                                                  London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
What is SQLite
           SQLite is a software library that
             implements a self-contained,
      serverless,zero-configuration, transactional
                 SQL database engine.



                 Serverless

                 Open Source
                                                      SQLite is a compact library.
                 Compact                             With all features enabled, the
                                                      library size can be less than
                                                    350KiB, depending on the target
                                                         platform and compiler
                                                         optimization settings.



          #TiLon                                                 London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
What is SQLite
           SQLite is a software library that
             implements a self-contained,
      serverless,zero-configuration, transactional
                 SQL database engine.



                 Serverless

                 Open Source

                 Compact




          #TiLon                                    London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
SQL Brief History


                 Based on RDBMS - Relational
                 Database Management System based
                 around Edgar F. Codd’s Relational
                 Model

                 Implements most of the SQL-92
                 standard.

                 Written by D. Richard Hipp in 2000




          #TiLon                                      London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
Ti.Database
            OPEN / INSTALL / REMOVE

                 EXECUTE Query

                       lastInsertRowId

                       rowsAffected

                       RESULT Sets

                            isValidRow

                            next



          #TiLon                                  London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
Table/DB Creation

                                                                       Create In GUI/
         Create In App                   Create via console
                                                                          Preload



                            CREATE TABLE "tbl1" (
                            	   "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
                            	   "rowValue" text
                            )



                                                  SQLite Database




          #TiLon                                                        London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
Basic DB usage
     // OPEN / INSTALL DATABASE -- SAFE
     var db = Ti.Database.install('/mydata/dynamicdata.sqlite', 'dynamicdata');
     	 // RESULT SET OBJECT
     	 var rs = db.execute('select * from tbl1');
     	 alert('Rows in table:' + rs.rowCount);
     	 while(rs.isValidRow()){
     	 	 Ti.API.info(rs.field(0) + ':' + rs.field(1));
     	 	 rs.next();
     	 }
     	 rs.close();
     	
     	 	 db.execute('INSERT into tbl1 (rowValue) values(date("now"))');
     	 	 alert('Last Insert ID:' + db.lastInsertRowId);

     // CLOSE DATABASE OBJECT
     db.close();


                            https://gist.github.com/1401196
          #TiLon                                            London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
TRANSACTION
     // OPEN / INSTALL DATABASE -- SAFE
     var db = Ti.Database.install('/mydata/dynamicdata.sqlite', 'dynamicdata');
     	 // RESULT SET OBJECT
     	 var rs = db.execute('select * from tbl1');
     	 alert('Rows in table:' + rs.rowCount);
     	 while(rs.isValidRow()){
     	 	 Ti.API.info(rs.field(0) + ':' + rs.field(1));
     	 	 rs.next();
     	 }
     	 rs.close();
     	 	 db.execute('BEGIN TRANSACTION');
     	 	 try{
     	 	 db.execute('INSERT into tbl1 (rowValue) values(date("now"))');
     	 	 db.execute('INSERT into tbl1 (rowValues) values(?)', new Date().getDate());
     	 	 alert('Last Insert ID:' + db.lastInsertRowId);
     	 	 } catch(e){
     	 	 	 alert(e.message);
     	 	 }
     	 	 db.execute('END TRANSACTION');

     // CLOSE DATABASE OBJECT
     db.close();

                            https://gist.github.com/1401366
          #TiLon                                                   London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
Android SQLite
                experiment
                      APK - download link:
    https://dl.dropbox.com/s/8h951ltd80rdyig/app.apk?dl=1


          #TiLon                          London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
SQLite Versions
                          What ships on a device: look at these tables.                                Supposedly ships with Android:

                            SQLite version                     Device OS                  SQLite version                   Device OS
                                                                                              3.5.9        Android 1.5-Cupcake
                  3.4.0                         iPhone OS 2.2.1                               3.5.9        Android 1.6-Donut
                                                                                              3.5.9        Android 2.1-Eclair
                  3.6.12                        iPhone OS 3.0 / 3.1                          3.6.22        Android 2.2-Froyo
                                                                                             3.6.22        Android 2.3.1-Gingerbread
                  3.6.22                        iPhone OS 4.0                                3.6.22        Android 2.3.3-Gingerbread
                                                                                              3.7.4        Android 3.0-Honeycomb
                  3.7.2                         iPhone OS 4.3                                 3.7.4        Android 3.1-Honeycomb
                                                                                              3.7.4        Android 3.2-Honeycomb
                  3.7.7                         iPhone OS 5.0                                 3.7.4        Android 4.0-Ice Cream Sandwich



                                                      3.5.9                2.1-update1   V9
                                                      3.6.22               2.2           HTC Desire
                                                      3.6.22               2.2.1         HTC Wildfire
                                                      3.6.22               2.2.1         HTC Magic
                                                      3.7.2                2.3.3         Desire HD
                                                      3.7.2                2.3.3         LG-P500
                                                      3.7.2                2.3.3         Desire HD
                                                      3.7.2                2.3.3         Nexus One
                                                      3.6.22               2.3.3         GT-I9100
                                                      3.7.2                2.3.3         HTC Wildfire S A510e
                                                      3.7.2                2.3.4         HTC Sensation Z710e
                                                      3.7.4                3.2           G100W
                                                      3.7.4                4.0.1         Galaxy Nexus
          #TiLon                                                                                                       London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
button1.addEventListener('click', function(){
   	 var alertDialog = Ti.UI.createAlertDialog({
   	 	 title: 'SQLite version check',
   	 	 message: "You are running SQLite " + result.field(0) + " on: " + Ti.Platform.name
   + ' ' + Ti.Platform.version + ' ' + Ti.Platform.model + 'nnPlease consider emailing
   this to me to build a reference resource of android OS to SQLite versions',
   	 	 csvData: result.field(0) + "," + Ti.Platform.name + ',' + Ti.Platform.version +
   ',' + Ti.Platform.model+','+new Date().getTime(),
   	 	 buttonNames: ['No Thanks', 'OK']
   	 });
   	 alertDialog.show();

   	 alertDialog.addEventListener('click', function(e){
   	 	 if(e.index === 1){
   	 	 	 var emailKet = Ti.UI.createEmailDialog({
   	 	 	 	 messageBody: 'Email Text',
   	 	 	 	 toRecipients: ['info@spiritquest.co.uk'],
   	 	 	 	 subject: 'SQLite android data gathering - London Titanium'
   	 	 	 });
   	 	 	 emailKet.open();
   	 	 }
   	 });
   });
   var db = Ti.Database.open('testData1');
   var result = db.execute("SELECT sqlite_version();");

                            https://gist.github.com/1401186
          #TiLon                                                  London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
ORMs



                            Object Relational Mapping

                            Apps need to scale

                            joli.js - Codestrong talk by Xavier Lacot




          #TiLon                                                        London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
SQLite thoughts
                            extension not required     TRANSACTIONS &
                                                       ROLLBACKS
                            DB stored in application
                            data directory             BLOBS in SQLite have
                                                       ROLLBACK protection.
                            BLOBS good for files
                            10-30Kb based on           Good for cache
                            SQLite version             management.

                            optimise fields:
                            INTEGERS, TEXT then
                            BLOB (table create
                            order)

          #TiLon                                               London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
SQLite Editors
                            Base

                            MesaSQLite

                            RazorSQL

                            SQLite Database
                            Browser

                            Firefox Browser
                            extension

                            Command Line

          #TiLon                              London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011
http://www.sqlite.org

            http://wiki.appcelerator.org

            http://developer.appcelerator.com/apidoc/mobile/latest/

            http://www.sqlite.org/changes.html

            @ketan on twitter - www.stereoartist.com/blog




         Thank You
          #TiLon                                            London Titanium - Nov 2011   @ketan


Thursday, 1 December 2011

More Related Content

Similar to SQLite - Dynamic Data in Titanium

Using object dependencies in sql server 2008 tech republic
Using object dependencies in sql server 2008   tech republicUsing object dependencies in sql server 2008   tech republic
Using object dependencies in sql server 2008 tech republic
Kaing Menglieng
 
Getting started with entity framework revised 9 09
Getting started with entity framework revised 9 09Getting started with entity framework revised 9 09
Getting started with entity framework revised 9 09
manisoft84
 
Xldb2011 tue 1055_tom_fastner
Xldb2011 tue 1055_tom_fastnerXldb2011 tue 1055_tom_fastner
Xldb2011 tue 1055_tom_fastner
liqiang xu
 
Synchronizing data with ibm tivoli directory integrator 6.1 redp4317
Synchronizing data with ibm tivoli directory integrator 6.1 redp4317Synchronizing data with ibm tivoli directory integrator 6.1 redp4317
Synchronizing data with ibm tivoli directory integrator 6.1 redp4317
Banking at Ho Chi Minh city
 
Michael Bayer Introduction to SQLAlchemy @ Postgres Open
Michael Bayer Introduction to SQLAlchemy @ Postgres OpenMichael Bayer Introduction to SQLAlchemy @ Postgres Open
Michael Bayer Introduction to SQLAlchemy @ Postgres Open
PostgresOpen
 
SQL Server Developer 70-433
SQL Server Developer 70-433SQL Server Developer 70-433
SQL Server Developer 70-433
jasonyousef
 
Digital Preservation Cloud Services for Libraries and Archives
Digital Preservation Cloud Services for Libraries and ArchivesDigital Preservation Cloud Services for Libraries and Archives
Digital Preservation Cloud Services for Libraries and Archives
Quyen L. Nguyen
 
Ibm lotus domino integration using ibm tivoli directory integrator redp4629
Ibm lotus domino integration using ibm tivoli directory integrator redp4629Ibm lotus domino integration using ibm tivoli directory integrator redp4629
Ibm lotus domino integration using ibm tivoli directory integrator redp4629
Banking at Ho Chi Minh city
 
Inb343 week2 sql server intro
Inb343 week2 sql server introInb343 week2 sql server intro
Inb343 week2 sql server intro
Fredlive503
 

Similar to SQLite - Dynamic Data in Titanium (20)

A brief introduction to SQLite PPT
A brief introduction to SQLite PPTA brief introduction to SQLite PPT
A brief introduction to SQLite PPT
 
Sqlite
SqliteSqlite
Sqlite
 
Sql lite presentation
Sql lite presentationSql lite presentation
Sql lite presentation
 
Managing Massive data of the IoT through cooperative semantic nodes
Managing Massive data of the IoT through cooperative semantic nodesManaging Massive data of the IoT through cooperative semantic nodes
Managing Massive data of the IoT through cooperative semantic nodes
 
Sq lite
Sq liteSq lite
Sq lite
 
Os Owens
Os OwensOs Owens
Os Owens
 
Using object dependencies in sql server 2008 tech republic
Using object dependencies in sql server 2008   tech republicUsing object dependencies in sql server 2008   tech republic
Using object dependencies in sql server 2008 tech republic
 
Getting started with entity framework
Getting started with entity framework Getting started with entity framework
Getting started with entity framework
 
Getting started with entity framework revised 9 09
Getting started with entity framework revised 9 09Getting started with entity framework revised 9 09
Getting started with entity framework revised 9 09
 
Xldb2011 tue 1055_tom_fastner
Xldb2011 tue 1055_tom_fastnerXldb2011 tue 1055_tom_fastner
Xldb2011 tue 1055_tom_fastner
 
Synchronizing data with ibm tivoli directory integrator 6.1 redp4317
Synchronizing data with ibm tivoli directory integrator 6.1 redp4317Synchronizing data with ibm tivoli directory integrator 6.1 redp4317
Synchronizing data with ibm tivoli directory integrator 6.1 redp4317
 
Michael Bayer Introduction to SQLAlchemy @ Postgres Open
Michael Bayer Introduction to SQLAlchemy @ Postgres OpenMichael Bayer Introduction to SQLAlchemy @ Postgres Open
Michael Bayer Introduction to SQLAlchemy @ Postgres Open
 
SQL Server Developer 70-433
SQL Server Developer 70-433SQL Server Developer 70-433
SQL Server Developer 70-433
 
Asp.Net 3.5 Part 2
Asp.Net 3.5 Part 2Asp.Net 3.5 Part 2
Asp.Net 3.5 Part 2
 
Digital Preservation Cloud Services for Libraries and Archives
Digital Preservation Cloud Services for Libraries and ArchivesDigital Preservation Cloud Services for Libraries and Archives
Digital Preservation Cloud Services for Libraries and Archives
 
Ibm lotus domino integration using ibm tivoli directory integrator redp4629
Ibm lotus domino integration using ibm tivoli directory integrator redp4629Ibm lotus domino integration using ibm tivoli directory integrator redp4629
Ibm lotus domino integration using ibm tivoli directory integrator redp4629
 
Sq lite
Sq liteSq lite
Sq lite
 
Inb343 week2 sql server intro
Inb343 week2 sql server introInb343 week2 sql server intro
Inb343 week2 sql server intro
 
Big Bad PostgreSQL: BI on a Budget
Big Bad PostgreSQL: BI on a BudgetBig Bad PostgreSQL: BI on a Budget
Big Bad PostgreSQL: BI on a Budget
 
Sql server difference faqs- 6
Sql server difference faqs- 6Sql server difference faqs- 6
Sql server difference faqs- 6
 

More from Ket Majmudar

Getting Started with Titanium Studio
Getting Started with Titanium StudioGetting Started with Titanium Studio
Getting Started with Titanium Studio
Ket Majmudar
 

More from Ket Majmudar (12)

Ti.connect Awesome UX/UI Strategy with T-10
Ti.connect  Awesome UX/UI Strategy with T-10 Ti.connect  Awesome UX/UI Strategy with T-10
Ti.connect Awesome UX/UI Strategy with T-10
 
JSONH & Mobile APIs
JSONH & Mobile APIsJSONH & Mobile APIs
JSONH & Mobile APIs
 
T-10 Session at Over The Air 2013
T-10 Session at Over The Air 2013T-10 Session at Over The Air 2013
T-10 Session at Over The Air 2013
 
Titanium London - URLs & Alloy vs CommonJS
Titanium London - URLs & Alloy vs CommonJSTitanium London - URLs & Alloy vs CommonJS
Titanium London - URLs & Alloy vs CommonJS
 
T-10 International Space Apps Challenge Presentation in London 2013
T-10 International Space Apps Challenge Presentation in London 2013T-10 International Space Apps Challenge Presentation in London 2013
T-10 International Space Apps Challenge Presentation in London 2013
 
London Titanium July 2012 Intro
London Titanium July 2012 IntroLondon Titanium July 2012 Intro
London Titanium July 2012 Intro
 
London Titanium July 2012 Intro
London Titanium July 2012 IntroLondon Titanium July 2012 Intro
London Titanium July 2012 Intro
 
Titanium setup
Titanium setupTitanium setup
Titanium setup
 
Kitchen Sink to App
Kitchen Sink to AppKitchen Sink to App
Kitchen Sink to App
 
Getting Started with Titanium Studio
Getting Started with Titanium StudioGetting Started with Titanium Studio
Getting Started with Titanium Studio
 
Titanium London - Going Social - June 2011
Titanium London - Going Social - June 2011Titanium London - Going Social - June 2011
Titanium London - Going Social - June 2011
 
How to build your own 3D Digital Camera rig
How to build your own 3D Digital Camera rig How to build your own 3D Digital Camera rig
How to build your own 3D Digital Camera rig
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

SQLite - Dynamic Data in Titanium

  • 1. SQLite & Titanium Who, How & Where #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 2. About Ketan Majmudar @ketan (twitter) spiritquest.co.uk stereoartist.com freakshowuk.com #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 3. What is SQLite SQLite is a software library that implements a self-contained, serverless,zero-configuration, transactional SQL database engine. Serverless Open Source Compact #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 4. What is SQLite SQLite is a software library that implements a self-contained, SQLite is an embedded SQL serverless,zero-configuration, transactional database engine. Unlike most SQL database engine. other SQL databases, SQLite does not have a separate server process. SQLite reads and writes Serverless directly to ordinary disk files. Open Source Compact #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 5. What is SQLite SQLite is a software library that implements a self-contained, serverless,zero-configuration, transactional SQL database engine. The code for SQLite is in the public domain and is thus free Serverless for use for any purpose, commercial or private. SQLite is Open Source currently found in more applications than we can count Compact including several high-profile projects. #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 6. What is SQLite SQLite is a software library that implements a self-contained, serverless,zero-configuration, transactional SQL database engine. Serverless Open Source SQLite is a compact library. Compact With all features enabled, the library size can be less than 350KiB, depending on the target platform and compiler optimization settings. #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 7. What is SQLite SQLite is a software library that implements a self-contained, serverless,zero-configuration, transactional SQL database engine. Serverless Open Source Compact #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 8. SQL Brief History Based on RDBMS - Relational Database Management System based around Edgar F. Codd’s Relational Model Implements most of the SQL-92 standard. Written by D. Richard Hipp in 2000 #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 9. Ti.Database OPEN / INSTALL / REMOVE EXECUTE Query lastInsertRowId rowsAffected RESULT Sets isValidRow next #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 10. Table/DB Creation Create In GUI/ Create In App Create via console Preload CREATE TABLE "tbl1" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "rowValue" text ) SQLite Database #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 11. Basic DB usage // OPEN / INSTALL DATABASE -- SAFE var db = Ti.Database.install('/mydata/dynamicdata.sqlite', 'dynamicdata'); // RESULT SET OBJECT var rs = db.execute('select * from tbl1'); alert('Rows in table:' + rs.rowCount); while(rs.isValidRow()){ Ti.API.info(rs.field(0) + ':' + rs.field(1)); rs.next(); } rs.close(); db.execute('INSERT into tbl1 (rowValue) values(date("now"))'); alert('Last Insert ID:' + db.lastInsertRowId); // CLOSE DATABASE OBJECT db.close(); https://gist.github.com/1401196 #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 12. TRANSACTION // OPEN / INSTALL DATABASE -- SAFE var db = Ti.Database.install('/mydata/dynamicdata.sqlite', 'dynamicdata'); // RESULT SET OBJECT var rs = db.execute('select * from tbl1'); alert('Rows in table:' + rs.rowCount); while(rs.isValidRow()){ Ti.API.info(rs.field(0) + ':' + rs.field(1)); rs.next(); } rs.close(); db.execute('BEGIN TRANSACTION'); try{ db.execute('INSERT into tbl1 (rowValue) values(date("now"))'); db.execute('INSERT into tbl1 (rowValues) values(?)', new Date().getDate()); alert('Last Insert ID:' + db.lastInsertRowId); } catch(e){ alert(e.message); } db.execute('END TRANSACTION'); // CLOSE DATABASE OBJECT db.close(); https://gist.github.com/1401366 #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 13. Android SQLite experiment APK - download link: https://dl.dropbox.com/s/8h951ltd80rdyig/app.apk?dl=1 #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 14. SQLite Versions What ships on a device: look at these tables. Supposedly ships with Android: SQLite version Device OS SQLite version Device OS 3.5.9 Android 1.5-Cupcake 3.4.0 iPhone OS 2.2.1 3.5.9 Android 1.6-Donut 3.5.9 Android 2.1-Eclair 3.6.12 iPhone OS 3.0 / 3.1 3.6.22 Android 2.2-Froyo 3.6.22 Android 2.3.1-Gingerbread 3.6.22 iPhone OS 4.0 3.6.22 Android 2.3.3-Gingerbread 3.7.4 Android 3.0-Honeycomb 3.7.2 iPhone OS 4.3 3.7.4 Android 3.1-Honeycomb 3.7.4 Android 3.2-Honeycomb 3.7.7 iPhone OS 5.0 3.7.4 Android 4.0-Ice Cream Sandwich 3.5.9 2.1-update1 V9 3.6.22 2.2 HTC Desire 3.6.22 2.2.1 HTC Wildfire 3.6.22 2.2.1 HTC Magic 3.7.2 2.3.3 Desire HD 3.7.2 2.3.3 LG-P500 3.7.2 2.3.3 Desire HD 3.7.2 2.3.3 Nexus One 3.6.22 2.3.3 GT-I9100 3.7.2 2.3.3 HTC Wildfire S A510e 3.7.2 2.3.4 HTC Sensation Z710e 3.7.4 3.2 G100W 3.7.4 4.0.1 Galaxy Nexus #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 15. button1.addEventListener('click', function(){ var alertDialog = Ti.UI.createAlertDialog({ title: 'SQLite version check', message: "You are running SQLite " + result.field(0) + " on: " + Ti.Platform.name + ' ' + Ti.Platform.version + ' ' + Ti.Platform.model + 'nnPlease consider emailing this to me to build a reference resource of android OS to SQLite versions', csvData: result.field(0) + "," + Ti.Platform.name + ',' + Ti.Platform.version + ',' + Ti.Platform.model+','+new Date().getTime(), buttonNames: ['No Thanks', 'OK'] }); alertDialog.show(); alertDialog.addEventListener('click', function(e){ if(e.index === 1){ var emailKet = Ti.UI.createEmailDialog({ messageBody: 'Email Text', toRecipients: ['info@spiritquest.co.uk'], subject: 'SQLite android data gathering - London Titanium' }); emailKet.open(); } }); }); var db = Ti.Database.open('testData1'); var result = db.execute("SELECT sqlite_version();"); https://gist.github.com/1401186 #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 16. ORMs Object Relational Mapping Apps need to scale joli.js - Codestrong talk by Xavier Lacot #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 17. SQLite thoughts extension not required TRANSACTIONS & ROLLBACKS DB stored in application data directory BLOBS in SQLite have ROLLBACK protection. BLOBS good for files 10-30Kb based on Good for cache SQLite version management. optimise fields: INTEGERS, TEXT then BLOB (table create order) #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 18. SQLite Editors Base MesaSQLite RazorSQL SQLite Database Browser Firefox Browser extension Command Line #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011
  • 19. http://www.sqlite.org http://wiki.appcelerator.org http://developer.appcelerator.com/apidoc/mobile/latest/ http://www.sqlite.org/changes.html @ketan on twitter - www.stereoartist.com/blog Thank You #TiLon London Titanium - Nov 2011 @ketan Thursday, 1 December 2011