SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Introduction to SQLite
in Adobe AIR 1.5
Peter Elst - Flash Platform Consultant
Why SQLite in Adobe AIR?
■ Embedded SQL Database Engine

■ Implements most of SQL92

■ Light-weight, cross-platform, open source

■ No setup, configuration or server required

■ Each database is contained within a single file
How do you use it?
How do you use it?
1. Create a File reference
How do you use it?
1. Create a File reference

2. Create an instance of flash.data.SQLConnection and
   flash.data.SQLStatement
How do you use it?
1. Create a File reference

2. Create an instance of flash.data.SQLConnection and
   flash.data.SQLStatement

3. Open the database connection
How do you use it?
1. Create a File reference

2. Create an instance of flash.data.SQLConnection and
   flash.data.SQLStatement

3. Open the database connection

4. Specify the connection and SQL query to run
How do you use it?
1. Create a File reference

2. Create an instance of flash.data.SQLConnection and
   flash.data.SQLStatement

3. Open the database connection

4. Specify the connection and SQL query to run

5. Run SQLStatement.execute()
How do you use it?
 import flash.filesystem.File;
 import flash.data.*;

 var dbFile:File =
 File.applicationStorageDirectory.resolvePath(quot;contacts.dbquot;);

 var sqlConn:SQLConnection = new SQLConnection();
 var sqlStatement:SQLStatement = new SQLStatement();

 sqlConn.open(dbFile);

 sqlStatement.sqlConnection = sqlConn;
 sqlStatement.text = quot;SELECT * FROM contactsquot;;
 sqlStatement.execute();

 var result:Array = sqlStatement.getResult().data;
Synchronous versus Asynchronous
■ Synchronous - blocks application until result is available

   var sqlConn:SQLConnection = new SQLConnection();
   sqlConn.open(dbFile);

   var result:SQLResult = sqlConn.getResult().result;


■ Asynchronous - uses events and event listeners

   var sqlConn:SQLConnection = new SQLConnection();

   sqlConn.addEventListener(SQLResultEvent.RESULT, onSQLResult);
   sqlConn.addEventListener(SQLResultEvent.ERROR, onSQLError);

   sqlConn.openAsync(dbFile);
flash.data.SQLConnection
■ Connects to the database file

■ Provides events for asynchronous use

■ Schema access
flash.data.SQLStatement
■ Executes a SQL query on the specified database connection

■ Provides events for asynchronous use

■ Supports result paging
Storage types
■ NULL - NULL value (null)

■ INTEGER - signed integer (int)

■ REAL - floating point (Number)

■ TEXT - UTF16 text string (String)

■ BLOB - blob of data
SQLStatement Parameters
■ The parameters feature protects your SQL statements from
  SQL injection

  var sqlStatement:SQLStatement = new SQLStatement();
  sqlStatement.sqlConnection = sqlConn;
  sqlStatement.text = quot;SELECT * FROM contacts WHERE id = @IDquot;;
  sqlStatement.parameters[quot;@IDquot;] = someVariable;
  sqlStatement.execute();


■ You can use the @ or : symbol to denote a parameter to be
  replaced, works both string based as index based

  sqlStatement.parameters[0] = someVariable;
Result Paging
■ Paging allows you to limit the amount of rows you get
  returned when doing a select operation

  var sqlStatement:SQLStatement = new SQLStatement();
  sqlStatement.sqlConnection = sqlConn;
  sqlStatement.text = quot;SELECT * FROM contactsquot;;
  sqlStatement.execute(10);


■ You can get the next batch of rows returned by calling the
  next method on the SQLStatement instance

  sqlStatement.next();
flash.data.SQLResult
■ SQLResult.data - array of objects for each row of the result

■ SQLResult.complete - returns a boolean indicating whether
  or not the full result was shown

■ SQLResult.lastInsertRowID - return id for the last row that
  was inserted

■ SQLResult.rowsAffected - number of rows affected by an
  insert, update or delete operation
Transactions
■ Transactions allow multiple SQL statements to run within one
  write operation to the database

■ Much more optimized way of handling large insert operations,
  allows rollback of the complete transaction if an error occurs

 var sqlStatement:SQLStatement = new SQLStatement();
 sqlStatement.sqlConnection = sqlConn;
 sqlStatement.text = quot;INSERT into contacts VALUES (@NAME, @EMAIL)quot;;

 sqlConn.begin();
 for(var i:uint=0; i<contacts.length; i++) {
   sqlStatement.parameters[quot;@NAMEquot;] = contacts[i].name;
   sqlStatement.parameters[quot;@EMAILquot;] = contacts[i].email;
   sqlStatement.execute();
 }
 sqlConn.commit();
Database Schema
■ Allows you to introspect tables, views, columns, indices, triggers

 var sqlConn:SQLConnection = new SQLConnection();
 sqlConn.open(dbFile);

 sqlConn.loadSchema();
 var result:SQLSchemaResult = sqlConn.getSchemaResult();

 var table:SQLTableSchema = result.tables[0];
 var column:SQLColumnSchema = table.columns[0];

 trace(column.name);
 // returns name of the first column in the first table
Encrypted database support
■ New feature in AIR 1.5

■ Allows you to encrypt the SQLite database

■ ByteArray as an encryption key when opening the
  flash.data.SQLConnection

■ Database must be encrypted when it is created

■ Use SQLConnection.reencrypt([ByteArray]) to change the
  encryption key on a database
Encrypted database support
■ Simple example (not secure)

   var encryptionKey:ByteArray = new ByteArray();
   encryptionKey.writeUTFBytes(quot;notverysecretpasswordquot;);

   var sqlConn:SQLConnection = new SQLConnection();

   sqlConn.openAsync(dbFile, SQLMode.CREATE, null, false, 1024,
   encryptionKey);


■ For additional security:

 ■ Bundle the encrypted database with your AIR app

 ■ Get user input for the password rather than hardcoding it

 ■ Use the EncryptionGenerator class from as3corelib.swc
Demo time
Resources
■ Adobe AIR Developer Center
  www.adobe.com/devnet/air/

■ Adobe AIR 1.5 Cookbook (O'Reilly)

■ www.peterelst.com | info@peterelst.com

Weitere ähnliche Inhalte

Was ist angesagt?

MySQL Replication Update - DEbconf 2020 presentation
MySQL Replication Update - DEbconf 2020 presentationMySQL Replication Update - DEbconf 2020 presentation
MySQL Replication Update - DEbconf 2020 presentationDave Stokes
 
Data management with ado
Data management with adoData management with ado
Data management with adoDinesh kumar
 
Codemotion 2013: Feliz 15 aniversario, SQL Injection
Codemotion 2013: Feliz 15 aniversario, SQL InjectionCodemotion 2013: Feliz 15 aniversario, SQL Injection
Codemotion 2013: Feliz 15 aniversario, SQL InjectionChema Alonso
 
Synapse india reviews on php and sql
Synapse india reviews on php and sqlSynapse india reviews on php and sql
Synapse india reviews on php and sqlsaritasingh19866
 
cPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven FeaturescPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven FeaturesDave Stokes
 
Struts database access
Struts database accessStruts database access
Struts database accessAbass Ndiaye
 
Time-Based Blind SQL Injection Using Heavy Queries
Time-Based Blind SQL Injection Using Heavy QueriesTime-Based Blind SQL Injection Using Heavy Queries
Time-Based Blind SQL Injection Using Heavy QueriesChema Alonso
 
Architecture Components
Architecture Components Architecture Components
Architecture Components DataArt
 
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source SummitMySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source SummitDave Stokes
 
Sql server ___________session_18(stored procedures)
Sql server  ___________session_18(stored procedures)Sql server  ___________session_18(stored procedures)
Sql server ___________session_18(stored procedures)Ehtisham Ali
 
SQL Server 2016 RC3 Always Encryption
SQL Server 2016 RC3 Always Encryption SQL Server 2016 RC3 Always Encryption
SQL Server 2016 RC3 Always Encryption sultankhan
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursorsinfo_zybotech
 
Wicket Security Presentation
Wicket Security PresentationWicket Security Presentation
Wicket Security Presentationmrmean
 
Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!Ryosuke Uchitate
 

Was ist angesagt? (19)

Android - Saving data
Android - Saving dataAndroid - Saving data
Android - Saving data
 
Backendless apps
Backendless appsBackendless apps
Backendless apps
 
MySQL Replication Update - DEbconf 2020 presentation
MySQL Replication Update - DEbconf 2020 presentationMySQL Replication Update - DEbconf 2020 presentation
MySQL Replication Update - DEbconf 2020 presentation
 
Data management with ado
Data management with adoData management with ado
Data management with ado
 
Windowsosauthent
WindowsosauthentWindowsosauthent
Windowsosauthent
 
Codemotion 2013: Feliz 15 aniversario, SQL Injection
Codemotion 2013: Feliz 15 aniversario, SQL InjectionCodemotion 2013: Feliz 15 aniversario, SQL Injection
Codemotion 2013: Feliz 15 aniversario, SQL Injection
 
spring-tutorial
spring-tutorialspring-tutorial
spring-tutorial
 
Synapse india reviews on php and sql
Synapse india reviews on php and sqlSynapse india reviews on php and sql
Synapse india reviews on php and sql
 
cPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven FeaturescPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven Features
 
Struts database access
Struts database accessStruts database access
Struts database access
 
Time-Based Blind SQL Injection Using Heavy Queries
Time-Based Blind SQL Injection Using Heavy QueriesTime-Based Blind SQL Injection Using Heavy Queries
Time-Based Blind SQL Injection Using Heavy Queries
 
Architecture Components
Architecture Components Architecture Components
Architecture Components
 
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source SummitMySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
 
2nd-Order-SQLi-Josh
2nd-Order-SQLi-Josh2nd-Order-SQLi-Josh
2nd-Order-SQLi-Josh
 
Sql server ___________session_18(stored procedures)
Sql server  ___________session_18(stored procedures)Sql server  ___________session_18(stored procedures)
Sql server ___________session_18(stored procedures)
 
SQL Server 2016 RC3 Always Encryption
SQL Server 2016 RC3 Always Encryption SQL Server 2016 RC3 Always Encryption
SQL Server 2016 RC3 Always Encryption
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursors
 
Wicket Security Presentation
Wicket Security PresentationWicket Security Presentation
Wicket Security Presentation
 
Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!
 

Ähnlich wie Introduction to SQLite in Adobe AIR 1.5

Introduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIRIntroduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIRPeter Elst
 
Get database properties using power shell in sql server 2008 techrepublic
Get database properties using power shell in sql server 2008   techrepublicGet database properties using power shell in sql server 2008   techrepublic
Get database properties using power shell in sql server 2008 techrepublicKaing Menglieng
 
Windows Azure and a little SQL Data Services
Windows Azure and a little SQL Data ServicesWindows Azure and a little SQL Data Services
Windows Azure and a little SQL Data Servicesukdpe
 
Sql Injection and Entity Frameworks
Sql Injection and Entity FrameworksSql Injection and Entity Frameworks
Sql Injection and Entity FrameworksRich Helton
 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actionsAren Zomorodian
 
Database Programming Techniques
Database Programming TechniquesDatabase Programming Techniques
Database Programming TechniquesRaji Ghawi
 
Azure SQL Database - Connectivity Best Practices
Azure SQL Database - Connectivity Best PracticesAzure SQL Database - Connectivity Best Practices
Azure SQL Database - Connectivity Best PracticesJose Manuel Jurado Diaz
 
Database presentation
Database presentationDatabase presentation
Database presentationwebhostingguy
 
JDBC for CSQL Database
JDBC for CSQL DatabaseJDBC for CSQL Database
JDBC for CSQL Databasejitendral
 
General Principles of Web Security
General Principles of Web SecurityGeneral Principles of Web Security
General Principles of Web Securityjemond
 
Asp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptxAsp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptxsridharu1981
 
DIWE - Working with MySQL Databases
DIWE - Working with MySQL DatabasesDIWE - Working with MySQL Databases
DIWE - Working with MySQL DatabasesRasan Samarasinghe
 
Python SQite3 database Tutorial | SQlite Database
Python SQite3 database Tutorial | SQlite DatabasePython SQite3 database Tutorial | SQlite Database
Python SQite3 database Tutorial | SQlite DatabaseElangovanTechNotesET
 
Deeply Declarative Data Pipelines
Deeply Declarative Data PipelinesDeeply Declarative Data Pipelines
Deeply Declarative Data PipelinesHostedbyConfluent
 
03. sql and other injection module v17
03. sql and other injection module v1703. sql and other injection module v17
03. sql and other injection module v17Eoin Keary
 
How to connect sql server to oracle server
How to connect sql server to oracle serverHow to connect sql server to oracle server
How to connect sql server to oracle serverGustavo Bernardo
 

Ähnlich wie Introduction to SQLite in Adobe AIR 1.5 (20)

Introduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIRIntroduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIR
 
Get database properties using power shell in sql server 2008 techrepublic
Get database properties using power shell in sql server 2008   techrepublicGet database properties using power shell in sql server 2008   techrepublic
Get database properties using power shell in sql server 2008 techrepublic
 
Windows Azure and a little SQL Data Services
Windows Azure and a little SQL Data ServicesWindows Azure and a little SQL Data Services
Windows Azure and a little SQL Data Services
 
Sql Injection and Entity Frameworks
Sql Injection and Entity FrameworksSql Injection and Entity Frameworks
Sql Injection and Entity Frameworks
 
Web Technologies - forms and actions
Web Technologies -  forms and actionsWeb Technologies -  forms and actions
Web Technologies - forms and actions
 
Database Programming Techniques
Database Programming TechniquesDatabase Programming Techniques
Database Programming Techniques
 
Azure SQL Database - Connectivity Best Practices
Azure SQL Database - Connectivity Best PracticesAzure SQL Database - Connectivity Best Practices
Azure SQL Database - Connectivity Best Practices
 
Database presentation
Database presentationDatabase presentation
Database presentation
 
JDBC in Servlets
JDBC in ServletsJDBC in Servlets
JDBC in Servlets
 
JDBC for CSQL Database
JDBC for CSQL DatabaseJDBC for CSQL Database
JDBC for CSQL Database
 
General Principles of Web Security
General Principles of Web SecurityGeneral Principles of Web Security
General Principles of Web Security
 
Asp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptxAsp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptx
 
Sql injection
Sql injectionSql injection
Sql injection
 
DIWE - Working with MySQL Databases
DIWE - Working with MySQL DatabasesDIWE - Working with MySQL Databases
DIWE - Working with MySQL Databases
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
Python SQite3 database Tutorial | SQlite Database
Python SQite3 database Tutorial | SQlite DatabasePython SQite3 database Tutorial | SQlite Database
Python SQite3 database Tutorial | SQlite Database
 
Sql injection
Sql injectionSql injection
Sql injection
 
Deeply Declarative Data Pipelines
Deeply Declarative Data PipelinesDeeply Declarative Data Pipelines
Deeply Declarative Data Pipelines
 
03. sql and other injection module v17
03. sql and other injection module v1703. sql and other injection module v17
03. sql and other injection module v17
 
How to connect sql server to oracle server
How to connect sql server to oracle serverHow to connect sql server to oracle server
How to connect sql server to oracle server
 

Mehr von Peter Elst

P2P on the local network
P2P on the local networkP2P on the local network
P2P on the local networkPeter Elst
 
P2P with Flash Player 10.1
P2P with Flash Player 10.1P2P with Flash Player 10.1
P2P with Flash Player 10.1Peter Elst
 
Big boys and their litl toys
Big boys and their litl toysBig boys and their litl toys
Big boys and their litl toysPeter Elst
 
Yes, you can do that with AIR 2.0
Yes, you can do that with AIR 2.0Yes, you can do that with AIR 2.0
Yes, you can do that with AIR 2.0Peter Elst
 
FATC - AIR 2.0 workshop
FATC - AIR 2.0 workshopFATC - AIR 2.0 workshop
FATC - AIR 2.0 workshopPeter Elst
 
Developing with Adobe AIR
Developing with Adobe AIRDeveloping with Adobe AIR
Developing with Adobe AIRPeter Elst
 
Introduction to AS3Signals
Introduction to AS3SignalsIntroduction to AS3Signals
Introduction to AS3SignalsPeter Elst
 
The Secret Life of a Flash Freelancer
The Secret Life of a Flash FreelancerThe Secret Life of a Flash Freelancer
The Secret Life of a Flash FreelancerPeter Elst
 
Getting Creative with Adobe AIR
Getting Creative with Adobe AIRGetting Creative with Adobe AIR
Getting Creative with Adobe AIRPeter Elst
 
Creative Programming in ActionScript 3.0
Creative Programming in ActionScript 3.0Creative Programming in ActionScript 3.0
Creative Programming in ActionScript 3.0Peter Elst
 
RIA meets Desktop
RIA meets DesktopRIA meets Desktop
RIA meets DesktopPeter Elst
 
Object-Oriented ActionScript 3.0
Object-Oriented ActionScript 3.0Object-Oriented ActionScript 3.0
Object-Oriented ActionScript 3.0Peter Elst
 
The Evolution of the Flash Platform
The Evolution of the Flash PlatformThe Evolution of the Flash Platform
The Evolution of the Flash PlatformPeter Elst
 
RIA meets Desktop
RIA meets DesktopRIA meets Desktop
RIA meets DesktopPeter Elst
 
SkillsMatter - In-the-Brain session - What's new in ActionScript 3.0
SkillsMatter - In-the-Brain session - What's new in ActionScript 3.0SkillsMatter - In-the-Brain session - What's new in ActionScript 3.0
SkillsMatter - In-the-Brain session - What's new in ActionScript 3.0Peter Elst
 

Mehr von Peter Elst (15)

P2P on the local network
P2P on the local networkP2P on the local network
P2P on the local network
 
P2P with Flash Player 10.1
P2P with Flash Player 10.1P2P with Flash Player 10.1
P2P with Flash Player 10.1
 
Big boys and their litl toys
Big boys and their litl toysBig boys and their litl toys
Big boys and their litl toys
 
Yes, you can do that with AIR 2.0
Yes, you can do that with AIR 2.0Yes, you can do that with AIR 2.0
Yes, you can do that with AIR 2.0
 
FATC - AIR 2.0 workshop
FATC - AIR 2.0 workshopFATC - AIR 2.0 workshop
FATC - AIR 2.0 workshop
 
Developing with Adobe AIR
Developing with Adobe AIRDeveloping with Adobe AIR
Developing with Adobe AIR
 
Introduction to AS3Signals
Introduction to AS3SignalsIntroduction to AS3Signals
Introduction to AS3Signals
 
The Secret Life of a Flash Freelancer
The Secret Life of a Flash FreelancerThe Secret Life of a Flash Freelancer
The Secret Life of a Flash Freelancer
 
Getting Creative with Adobe AIR
Getting Creative with Adobe AIRGetting Creative with Adobe AIR
Getting Creative with Adobe AIR
 
Creative Programming in ActionScript 3.0
Creative Programming in ActionScript 3.0Creative Programming in ActionScript 3.0
Creative Programming in ActionScript 3.0
 
RIA meets Desktop
RIA meets DesktopRIA meets Desktop
RIA meets Desktop
 
Object-Oriented ActionScript 3.0
Object-Oriented ActionScript 3.0Object-Oriented ActionScript 3.0
Object-Oriented ActionScript 3.0
 
The Evolution of the Flash Platform
The Evolution of the Flash PlatformThe Evolution of the Flash Platform
The Evolution of the Flash Platform
 
RIA meets Desktop
RIA meets DesktopRIA meets Desktop
RIA meets Desktop
 
SkillsMatter - In-the-Brain session - What's new in ActionScript 3.0
SkillsMatter - In-the-Brain session - What's new in ActionScript 3.0SkillsMatter - In-the-Brain session - What's new in ActionScript 3.0
SkillsMatter - In-the-Brain session - What's new in ActionScript 3.0
 

Kürzlich hochgeladen

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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 2024Rafal Los
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Kürzlich hochgeladen (20)

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

Introduction to SQLite in Adobe AIR 1.5

  • 1. Introduction to SQLite in Adobe AIR 1.5 Peter Elst - Flash Platform Consultant
  • 2. Why SQLite in Adobe AIR? ■ Embedded SQL Database Engine ■ Implements most of SQL92 ■ Light-weight, cross-platform, open source ■ No setup, configuration or server required ■ Each database is contained within a single file
  • 3. How do you use it?
  • 4. How do you use it? 1. Create a File reference
  • 5. How do you use it? 1. Create a File reference 2. Create an instance of flash.data.SQLConnection and flash.data.SQLStatement
  • 6. How do you use it? 1. Create a File reference 2. Create an instance of flash.data.SQLConnection and flash.data.SQLStatement 3. Open the database connection
  • 7. How do you use it? 1. Create a File reference 2. Create an instance of flash.data.SQLConnection and flash.data.SQLStatement 3. Open the database connection 4. Specify the connection and SQL query to run
  • 8. How do you use it? 1. Create a File reference 2. Create an instance of flash.data.SQLConnection and flash.data.SQLStatement 3. Open the database connection 4. Specify the connection and SQL query to run 5. Run SQLStatement.execute()
  • 9. How do you use it? import flash.filesystem.File; import flash.data.*; var dbFile:File = File.applicationStorageDirectory.resolvePath(quot;contacts.dbquot;); var sqlConn:SQLConnection = new SQLConnection(); var sqlStatement:SQLStatement = new SQLStatement(); sqlConn.open(dbFile); sqlStatement.sqlConnection = sqlConn; sqlStatement.text = quot;SELECT * FROM contactsquot;; sqlStatement.execute(); var result:Array = sqlStatement.getResult().data;
  • 10. Synchronous versus Asynchronous ■ Synchronous - blocks application until result is available var sqlConn:SQLConnection = new SQLConnection(); sqlConn.open(dbFile); var result:SQLResult = sqlConn.getResult().result; ■ Asynchronous - uses events and event listeners var sqlConn:SQLConnection = new SQLConnection(); sqlConn.addEventListener(SQLResultEvent.RESULT, onSQLResult); sqlConn.addEventListener(SQLResultEvent.ERROR, onSQLError); sqlConn.openAsync(dbFile);
  • 11. flash.data.SQLConnection ■ Connects to the database file ■ Provides events for asynchronous use ■ Schema access
  • 12. flash.data.SQLStatement ■ Executes a SQL query on the specified database connection ■ Provides events for asynchronous use ■ Supports result paging
  • 13. Storage types ■ NULL - NULL value (null) ■ INTEGER - signed integer (int) ■ REAL - floating point (Number) ■ TEXT - UTF16 text string (String) ■ BLOB - blob of data
  • 14. SQLStatement Parameters ■ The parameters feature protects your SQL statements from SQL injection var sqlStatement:SQLStatement = new SQLStatement(); sqlStatement.sqlConnection = sqlConn; sqlStatement.text = quot;SELECT * FROM contacts WHERE id = @IDquot;; sqlStatement.parameters[quot;@IDquot;] = someVariable; sqlStatement.execute(); ■ You can use the @ or : symbol to denote a parameter to be replaced, works both string based as index based sqlStatement.parameters[0] = someVariable;
  • 15. Result Paging ■ Paging allows you to limit the amount of rows you get returned when doing a select operation var sqlStatement:SQLStatement = new SQLStatement(); sqlStatement.sqlConnection = sqlConn; sqlStatement.text = quot;SELECT * FROM contactsquot;; sqlStatement.execute(10); ■ You can get the next batch of rows returned by calling the next method on the SQLStatement instance sqlStatement.next();
  • 16. flash.data.SQLResult ■ SQLResult.data - array of objects for each row of the result ■ SQLResult.complete - returns a boolean indicating whether or not the full result was shown ■ SQLResult.lastInsertRowID - return id for the last row that was inserted ■ SQLResult.rowsAffected - number of rows affected by an insert, update or delete operation
  • 17. Transactions ■ Transactions allow multiple SQL statements to run within one write operation to the database ■ Much more optimized way of handling large insert operations, allows rollback of the complete transaction if an error occurs var sqlStatement:SQLStatement = new SQLStatement(); sqlStatement.sqlConnection = sqlConn; sqlStatement.text = quot;INSERT into contacts VALUES (@NAME, @EMAIL)quot;; sqlConn.begin(); for(var i:uint=0; i<contacts.length; i++) { sqlStatement.parameters[quot;@NAMEquot;] = contacts[i].name; sqlStatement.parameters[quot;@EMAILquot;] = contacts[i].email; sqlStatement.execute(); } sqlConn.commit();
  • 18. Database Schema ■ Allows you to introspect tables, views, columns, indices, triggers var sqlConn:SQLConnection = new SQLConnection(); sqlConn.open(dbFile); sqlConn.loadSchema(); var result:SQLSchemaResult = sqlConn.getSchemaResult(); var table:SQLTableSchema = result.tables[0]; var column:SQLColumnSchema = table.columns[0]; trace(column.name); // returns name of the first column in the first table
  • 19. Encrypted database support ■ New feature in AIR 1.5 ■ Allows you to encrypt the SQLite database ■ ByteArray as an encryption key when opening the flash.data.SQLConnection ■ Database must be encrypted when it is created ■ Use SQLConnection.reencrypt([ByteArray]) to change the encryption key on a database
  • 20. Encrypted database support ■ Simple example (not secure) var encryptionKey:ByteArray = new ByteArray(); encryptionKey.writeUTFBytes(quot;notverysecretpasswordquot;); var sqlConn:SQLConnection = new SQLConnection(); sqlConn.openAsync(dbFile, SQLMode.CREATE, null, false, 1024, encryptionKey); ■ For additional security: ■ Bundle the encrypted database with your AIR app ■ Get user input for the password rather than hardcoding it ■ Use the EncryptionGenerator class from as3corelib.swc
  • 22. Resources ■ Adobe AIR Developer Center www.adobe.com/devnet/air/ ■ Adobe AIR 1.5 Cookbook (O'Reilly) ■ www.peterelst.com | info@peterelst.com