SlideShare a Scribd company logo
1 of 23
Download to read offline
MODULE 9: SQLITE AND PYTHON (A BRIEF
INTRODUCTION)
SQL and Scripting Training
(C) 2020-2021 Highervista, LLC 1
2
TOPICS
Introduction to Python and SQLite
Import and Connect
The Cursor and Methods within the Cursor
12/12/20 (C) 2020-2021 Highervista, LLC
INTRODUCTION TO PYTHON
AND SQLITE
SQL and Scripting Training
12/12/20 (C) 2020-2021 Highervista, LLC 3
4
WORKING WITH SQLITE
As you can see from working with SQLite’s CLI or a GUI like
DB Browser for SQLite, maintaining a company’s database
would take quite a bit of expertise and devoted time
Using a programming language like Python (and others) can
automate quite a bit of the tasks necessary to maintain the
database
In addition, with a programming language, you can
(optionally) create a user-specific GUI for the company’s
database
12/12/20 (C) 2020-2021 Highervista, LLC
5
A NOTE ABOUT PYTHON
Your next course will be about the Python Programming Language
We will not be covering Python in any detail in this module
Our goal with this module is to introduce general Python concepts, as they
relate to SQLite
More detail will be presented in the Python course, so please consider this
module as a ‘conceptual’ (first pass) overview of Python and SQLite
For the SQL assessment, Python will not be a part of the assessment
12/12/20 (C) 2020-2021 Highervista, LLC
6
USING PYTHON
Assuming that you have a database created (as we’ve
done in this course), you will need to have the
programming language (like Python) connect to the
database.
This ‘connection’ is the link between an existing
database and the Python programming language.
12/12/20 (C) 2020-2021 Highervista, LLC
IMPORT AND CONNECT SQL and Scripting Training
12/12/20 (C) 2020-2021 Highervista, LLC 7
8
What is Needed
In Python, you will need the sqlite3
module (the same one that we used)
The sqlite3 package is ‘imported’ into
Python by the use of the import
command.
After sqlite3 is imported, a
connection between Python and the
specific sqlite3 database must be
made so that Python can access the
specific database.
Python
CONNECTING PYTHON TO AN
SQLITE DATABASE
9
ONCE CONNECTED – CURSOR ‘OBJECT’
Once the database is successfully connected
to Python, a cursor object is established.
A cursor object is a way that Python can
perform actions on the database.
Within the cursor object, there is an
execute() method that allows actions to be
performed on the Sqlite3 database.
For example, the screen image shows the
cursor connection and the ability through the
connection to run a SELECT command. We’ve
done quite a few SELECT commands in our
course.
Establish a connection, then use a cursor object.
The execution of the SELECT moves the ‘result set’
from the query to a location where the data can be
worked on by the Python program.
12/12/20 (C) 2020-2021 Highervista, LLC
10
USING FETCHONE()
Now that a SELECT command was
executed (a SELECT *), we can get one
specific row by using the fetchone()
command.
With fetchone(), we can make changes to
the one item that we ‘fetched.’
Any changes to the fetched record can be
made to the particular record by Python,
based on the decisions in the program.
fetchone() method call
Results of fetchone() method call to example database
12/12/20 (C) 2020-2021 Highervista, LLC
11
PYTHON
Python can ‘seed’ (or set up) the connection and, within the cursor object,
can also set up the particular methods that can be used to maintain the
database.
This avoids an individual who works daily with the company’s database
from knowing the specifics about connection objects and methods.
We leave this knowledge for the programmer to code, test and turn over
to the user.
12/12/20 (C) 2020-2021 Highervista, LLC
THE CURSOR AND METHODS
WITHIN THE CURSOR
SQL and Scripting Training
12/12/20 (C) 2020-2021 Highervista, LLC 12
13
USING THE FETCHALL() METHOD
The fetchall() methods returns all records that can
be worked on (modified) in the Python program.
Depending on the database size, this can be a
huge amount of data.
For our example database, we have a smaller set
of data.
fetchall() method embedded within print command
Result set
12/12/20 (C) 2020-2021 Highervista, LLC
14
PYTHON, EXAMPLE INSERT OF 1 RECORD
Python can be used to insert records into a
specific Sqlite3 table.
Here’s an example where records are
inserted into the consumers table by Python
(first line).
The second line prints the record.
Using the cursor, do an INSERT into a Sqlite3 table on
a previously connected database.
Results of the INSERT printed out.
12/12/20 (C) 2020-2021 Highervista, LLC
15
PYTHON, EXAMPLE OF A LIST OF INSERTED RECORDS
We can INSERT multiple records into
the database using Python.
Python used to set up multiple
records that are INSERTed
Print verification
12/12/20 (C) 2020-2021 Highervista, LLC
16
COMMIT
The cursor that is established between the Python
program and Sqlite3 helps facilitate the work
between the programming language and the
database.
The changes are not made until the transactions
are committed.
The commit() method is part of the connection
object that was first setup to connect the database
to the programming language.
The commit() method of the connection
object makes the data ‘persistent’ in
the database.
12/12/20 (C) 2020-2021 Highervista, LLC
17
VERIFYING THE COMMIT
Once the Python program selects the
data to be changed (modified or
inserted), and the commit is completed
successfully, you can use a tool like the
DB Browser for SQLite to view the
data on the database.
12/12/20 (C) 2020-2021 Highervista, LLC
PYTHON/SQLITE SUMMARY SQL and Scripting Training
12/12/20 (C) 2020-2021 Highervista, LLC 18
19
PYTHON AND SQLITE SUMMARY
You can connect an SQLite database to a Python
program by using a connection object.
The connection object sets up a cursor, where work by
Python can be done on the database.
The cursor has several ‘methods’ to get data from the
database and to place data back into the database,
once Python code is executed on the particular
database.
A commit is required to ensure that the changes are
‘persistent’ on the database.
12/12/20 (C) 2020-2021 Highervista, LLC
20
REFERENCE
McFarland, R. (2020). Published Articles: Ron McFarland.
Retrieved December 03, 2020, from https://medium.com/@highervista
12/12/20 (C) 2020-2021 Highervista, LLC
21
INTRODUCTION
Ron McFarland
Technologist, Educator
Source: Microsoft Images
22
ABOUT THIS COURSE
This course is distributed free. I use several
sources. But importantly, I use the book noted
on the next slide.
If you are using these PowerPoints, please
attribute Highervista, LLC and me (Ron
McFarland). IN ADDITION, please attribute
the author noted on the next slide, as the
author’s textbook provides essential
information for this course.
Source: Microsoft Images
23
INTRODUCTION
This course is offered to you free. HOWEVER, please
purchase the following book, as it is a primary resource for
this course. I do not make any $ from this course or this
book. So, since a handful of good content is derived from the
following text, please support this author!
Title: SQL Quickstart Guide
Author: Walter Shields
Available: Amazon, B&N, and through ClydeBank media
website at:
https://www.clydebankmedia.com/books/programming-
tech/sql-quickstart-guide

More Related Content

What's hot

Dbms important questions and answers
Dbms important questions and answersDbms important questions and answers
Dbms important questions and answersLakshmiSarvani6
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresSteven Johnson
 
BIS 245 OUTLET Achievement Education--bis245outlet.com
BIS 245 OUTLET Achievement Education--bis245outlet.comBIS 245 OUTLET Achievement Education--bis245outlet.com
BIS 245 OUTLET Achievement Education--bis245outlet.comagathachristie179
 
BIS 245 OUTLET Inspiring Innovation--bis245outlet.com
 BIS 245 OUTLET Inspiring Innovation--bis245outlet.com BIS 245 OUTLET Inspiring Innovation--bis245outlet.com
BIS 245 OUTLET Inspiring Innovation--bis245outlet.comwilliamwordsworth45
 
BIS 245 OUTLET Introduction Education--bis245outlet.com
BIS 245 OUTLET Introduction Education--bis245outlet.comBIS 245 OUTLET Introduction Education--bis245outlet.com
BIS 245 OUTLET Introduction Education--bis245outlet.comagathachristie291
 
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.comBIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.comthomashard72
 
BIS 245 HOMEWORK Redefined Education--bis245homework.com
BIS 245 HOMEWORK Redefined Education--bis245homework.comBIS 245 HOMEWORK Redefined Education--bis245homework.com
BIS 245 HOMEWORK Redefined Education--bis245homework.comagathachristie241
 
BIS 245 HOMEWORK Become Exceptional--bis245homework.com
BIS 245 HOMEWORK Become Exceptional--bis245homework.comBIS 245 HOMEWORK Become Exceptional--bis245homework.com
BIS 245 HOMEWORK Become Exceptional--bis245homework.comKeatonJennings120
 
BIS 245 HOMEWORK Introduction Education--bis245homework.com
BIS 245 HOMEWORK Introduction Education--bis245homework.comBIS 245 HOMEWORK Introduction Education--bis245homework.com
BIS 245 HOMEWORK Introduction Education--bis245homework.comagathachristie256
 
Ado.net session01
Ado.net session01Ado.net session01
Ado.net session01Niit Care
 
BIS 245 Lessons in Excellence / bis245.com
BIS 245 Lessons in Excellence / bis245.comBIS 245 Lessons in Excellence / bis245.com
BIS 245 Lessons in Excellence / bis245.comkopiko33
 
BIS 245 Redefined Education--bis245.com
BIS 245 Redefined Education--bis245.comBIS 245 Redefined Education--bis245.com
BIS 245 Redefined Education--bis245.comagathachristie204
 
Dbms narrative question answers
Dbms narrative question answersDbms narrative question answers
Dbms narrative question answersshakhawat02
 
Database queries
Database queriesDatabase queries
Database queriesIIUM
 
Access lesson 02 Creating a Database
Access lesson 02 Creating a DatabaseAccess lesson 02 Creating a Database
Access lesson 02 Creating a DatabaseAram SE
 

What's hot (20)

Dbms important questions and answers
Dbms important questions and answersDbms important questions and answers
Dbms important questions and answers
 
Sq lite module7
Sq lite module7Sq lite module7
Sq lite module7
 
Ch 9 S Q L
Ch 9  S Q LCh 9  S Q L
Ch 9 S Q L
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome Measures
 
BIS 245 OUTLET Achievement Education--bis245outlet.com
BIS 245 OUTLET Achievement Education--bis245outlet.comBIS 245 OUTLET Achievement Education--bis245outlet.com
BIS 245 OUTLET Achievement Education--bis245outlet.com
 
BIS 245 OUTLET Inspiring Innovation--bis245outlet.com
 BIS 245 OUTLET Inspiring Innovation--bis245outlet.com BIS 245 OUTLET Inspiring Innovation--bis245outlet.com
BIS 245 OUTLET Inspiring Innovation--bis245outlet.com
 
BIS 245 OUTLET Introduction Education--bis245outlet.com
BIS 245 OUTLET Introduction Education--bis245outlet.comBIS 245 OUTLET Introduction Education--bis245outlet.com
BIS 245 OUTLET Introduction Education--bis245outlet.com
 
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.comBIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
 
BIS 245 HOMEWORK Redefined Education--bis245homework.com
BIS 245 HOMEWORK Redefined Education--bis245homework.comBIS 245 HOMEWORK Redefined Education--bis245homework.com
BIS 245 HOMEWORK Redefined Education--bis245homework.com
 
BIS 245 HOMEWORK Become Exceptional--bis245homework.com
BIS 245 HOMEWORK Become Exceptional--bis245homework.comBIS 245 HOMEWORK Become Exceptional--bis245homework.com
BIS 245 HOMEWORK Become Exceptional--bis245homework.com
 
BIS 245 HOMEWORK Introduction Education--bis245homework.com
BIS 245 HOMEWORK Introduction Education--bis245homework.comBIS 245 HOMEWORK Introduction Education--bis245homework.com
BIS 245 HOMEWORK Introduction Education--bis245homework.com
 
Ado.net session01
Ado.net session01Ado.net session01
Ado.net session01
 
BIS 245 Lessons in Excellence / bis245.com
BIS 245 Lessons in Excellence / bis245.comBIS 245 Lessons in Excellence / bis245.com
BIS 245 Lessons in Excellence / bis245.com
 
BIS 245 Redefined Education--bis245.com
BIS 245 Redefined Education--bis245.comBIS 245 Redefined Education--bis245.com
BIS 245 Redefined Education--bis245.com
 
6 database
6 database 6 database
6 database
 
Dbms narrative question answers
Dbms narrative question answersDbms narrative question answers
Dbms narrative question answers
 
ch4
ch4ch4
ch4
 
Database queries
Database queriesDatabase queries
Database queries
 
Viva voce
Viva voceViva voce
Viva voce
 
Access lesson 02 Creating a Database
Access lesson 02 Creating a DatabaseAccess lesson 02 Creating a Database
Access lesson 02 Creating a Database
 

Similar to Sq lite module9

Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.netNgeam Soly
 
Oracle Application Containers
Oracle Application ContainersOracle Application Containers
Oracle Application ContainersMarkus Flechtner
 
Introduction to ado
Introduction to adoIntroduction to ado
Introduction to adoHarman Bajwa
 
(CRUD) How To Connect To Microsoft Access Database Insert Update Delete Clear...
(CRUD) How To Connect To Microsoft Access Database Insert Update Delete Clear...(CRUD) How To Connect To Microsoft Access Database Insert Update Delete Clear...
(CRUD) How To Connect To Microsoft Access Database Insert Update Delete Clear...mauricemuteti2015
 
Key projects Data Science and Engineering
Key projects Data Science and EngineeringKey projects Data Science and Engineering
Key projects Data Science and EngineeringVijayananda Mohire
 
Key projects Data Science and Engineering
Key projects Data Science and EngineeringKey projects Data Science and Engineering
Key projects Data Science and EngineeringVijayananda Mohire
 
2017 10-oow-fma-application-containers-v01-final
2017 10-oow-fma-application-containers-v01-final2017 10-oow-fma-application-containers-v01-final
2017 10-oow-fma-application-containers-v01-finalMarkus Flechtner
 
SQL Server Integration Services with Oracle Database 10g
SQL Server Integration Services with Oracle Database 10gSQL Server Integration Services with Oracle Database 10g
SQL Server Integration Services with Oracle Database 10gLeidy Alexandra
 
Microsoft Access Database And C# Windows Forms Tutorial Visual Studio 2010
Microsoft Access Database And C# Windows Forms Tutorial Visual Studio 2010Microsoft Access Database And C# Windows Forms Tutorial Visual Studio 2010
Microsoft Access Database And C# Windows Forms Tutorial Visual Studio 2010mauricemuteti2015
 
Interface python with sql database.pdf
Interface python with sql database.pdfInterface python with sql database.pdf
Interface python with sql database.pdfMohammadImran709594
 
Interface python with sql database10.pdf
Interface python with sql database10.pdfInterface python with sql database10.pdf
Interface python with sql database10.pdfHiteshNandi
 
Visual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetVisual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetFaRid Adwa
 
Chapter 6 Interface Python with MYSQL.pptx
Chapter 6 Interface Python with MYSQL.pptxChapter 6 Interface Python with MYSQL.pptx
Chapter 6 Interface Python with MYSQL.pptxsarofba
 
Lo extraction part 3 extractor logic
Lo extraction   part 3 extractor logicLo extraction   part 3 extractor logic
Lo extraction part 3 extractor logicJNTU University
 

Similar to Sq lite module9 (20)

Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.net
 
Chapter -7.pptx
Chapter -7.pptxChapter -7.pptx
Chapter -7.pptx
 
Oracle Application Containers
Oracle Application ContainersOracle Application Containers
Oracle Application Containers
 
Unit4
Unit4Unit4
Unit4
 
Introduction to ado
Introduction to adoIntroduction to ado
Introduction to ado
 
(CRUD) How To Connect To Microsoft Access Database Insert Update Delete Clear...
(CRUD) How To Connect To Microsoft Access Database Insert Update Delete Clear...(CRUD) How To Connect To Microsoft Access Database Insert Update Delete Clear...
(CRUD) How To Connect To Microsoft Access Database Insert Update Delete Clear...
 
Key projects Data Science and Engineering
Key projects Data Science and EngineeringKey projects Data Science and Engineering
Key projects Data Science and Engineering
 
Key projects Data Science and Engineering
Key projects Data Science and EngineeringKey projects Data Science and Engineering
Key projects Data Science and Engineering
 
2017 10-oow-fma-application-containers-v01-final
2017 10-oow-fma-application-containers-v01-final2017 10-oow-fma-application-containers-v01-final
2017 10-oow-fma-application-containers-v01-final
 
unit 3.docx
unit 3.docxunit 3.docx
unit 3.docx
 
SQL Server Integration Services with Oracle Database 10g
SQL Server Integration Services with Oracle Database 10gSQL Server Integration Services with Oracle Database 10g
SQL Server Integration Services with Oracle Database 10g
 
Microsoft Access Database And C# Windows Forms Tutorial Visual Studio 2010
Microsoft Access Database And C# Windows Forms Tutorial Visual Studio 2010Microsoft Access Database And C# Windows Forms Tutorial Visual Studio 2010
Microsoft Access Database And C# Windows Forms Tutorial Visual Studio 2010
 
ADO.NET by ASP.NET Development Company in india
ADO.NET by ASP.NET  Development Company in indiaADO.NET by ASP.NET  Development Company in india
ADO.NET by ASP.NET Development Company in india
 
Sqlite3 databases
Sqlite3 databasesSqlite3 databases
Sqlite3 databases
 
Interface python with sql database.pdf
Interface python with sql database.pdfInterface python with sql database.pdf
Interface python with sql database.pdf
 
Interface python with sql database10.pdf
Interface python with sql database10.pdfInterface python with sql database10.pdf
Interface python with sql database10.pdf
 
Visual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetVisual Basic.Net & Ado.Net
Visual Basic.Net & Ado.Net
 
A
AA
A
 
Chapter 6 Interface Python with MYSQL.pptx
Chapter 6 Interface Python with MYSQL.pptxChapter 6 Interface Python with MYSQL.pptx
Chapter 6 Interface Python with MYSQL.pptx
 
Lo extraction part 3 extractor logic
Lo extraction   part 3 extractor logicLo extraction   part 3 extractor logic
Lo extraction part 3 extractor logic
 

More from Highervista

Cyber security training using virtual labs 3 cs umuc presentation august 2018
Cyber security training using virtual labs 3 cs umuc presentation august 2018Cyber security training using virtual labs 3 cs umuc presentation august 2018
Cyber security training using virtual labs 3 cs umuc presentation august 2018Highervista
 
Cyber security for manufacturers umuc cadf-ron mcfarland
Cyber security for manufacturers umuc cadf-ron mcfarlandCyber security for manufacturers umuc cadf-ron mcfarland
Cyber security for manufacturers umuc cadf-ron mcfarlandHighervista
 
Intro infosec version 2
Intro infosec version 2Intro infosec version 2
Intro infosec version 2Highervista
 
How to create a maker space v2 ebook
How to create a maker space v2 ebookHow to create a maker space v2 ebook
How to create a maker space v2 ebookHighervista
 
Love and silence v3 scribd slide share
Love and silence v3 scribd slide shareLove and silence v3 scribd slide share
Love and silence v3 scribd slide shareHighervista
 

More from Highervista (6)

Sq lite module3
Sq lite module3Sq lite module3
Sq lite module3
 
Cyber security training using virtual labs 3 cs umuc presentation august 2018
Cyber security training using virtual labs 3 cs umuc presentation august 2018Cyber security training using virtual labs 3 cs umuc presentation august 2018
Cyber security training using virtual labs 3 cs umuc presentation august 2018
 
Cyber security for manufacturers umuc cadf-ron mcfarland
Cyber security for manufacturers umuc cadf-ron mcfarlandCyber security for manufacturers umuc cadf-ron mcfarland
Cyber security for manufacturers umuc cadf-ron mcfarland
 
Intro infosec version 2
Intro infosec version 2Intro infosec version 2
Intro infosec version 2
 
How to create a maker space v2 ebook
How to create a maker space v2 ebookHow to create a maker space v2 ebook
How to create a maker space v2 ebook
 
Love and silence v3 scribd slide share
Love and silence v3 scribd slide shareLove and silence v3 scribd slide share
Love and silence v3 scribd slide share
 

Recently uploaded

Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 

Recently uploaded (20)

Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 

Sq lite module9

  • 1. MODULE 9: SQLITE AND PYTHON (A BRIEF INTRODUCTION) SQL and Scripting Training (C) 2020-2021 Highervista, LLC 1
  • 2. 2 TOPICS Introduction to Python and SQLite Import and Connect The Cursor and Methods within the Cursor 12/12/20 (C) 2020-2021 Highervista, LLC
  • 3. INTRODUCTION TO PYTHON AND SQLITE SQL and Scripting Training 12/12/20 (C) 2020-2021 Highervista, LLC 3
  • 4. 4 WORKING WITH SQLITE As you can see from working with SQLite’s CLI or a GUI like DB Browser for SQLite, maintaining a company’s database would take quite a bit of expertise and devoted time Using a programming language like Python (and others) can automate quite a bit of the tasks necessary to maintain the database In addition, with a programming language, you can (optionally) create a user-specific GUI for the company’s database 12/12/20 (C) 2020-2021 Highervista, LLC
  • 5. 5 A NOTE ABOUT PYTHON Your next course will be about the Python Programming Language We will not be covering Python in any detail in this module Our goal with this module is to introduce general Python concepts, as they relate to SQLite More detail will be presented in the Python course, so please consider this module as a ‘conceptual’ (first pass) overview of Python and SQLite For the SQL assessment, Python will not be a part of the assessment 12/12/20 (C) 2020-2021 Highervista, LLC
  • 6. 6 USING PYTHON Assuming that you have a database created (as we’ve done in this course), you will need to have the programming language (like Python) connect to the database. This ‘connection’ is the link between an existing database and the Python programming language. 12/12/20 (C) 2020-2021 Highervista, LLC
  • 7. IMPORT AND CONNECT SQL and Scripting Training 12/12/20 (C) 2020-2021 Highervista, LLC 7
  • 8. 8 What is Needed In Python, you will need the sqlite3 module (the same one that we used) The sqlite3 package is ‘imported’ into Python by the use of the import command. After sqlite3 is imported, a connection between Python and the specific sqlite3 database must be made so that Python can access the specific database. Python CONNECTING PYTHON TO AN SQLITE DATABASE
  • 9. 9 ONCE CONNECTED – CURSOR ‘OBJECT’ Once the database is successfully connected to Python, a cursor object is established. A cursor object is a way that Python can perform actions on the database. Within the cursor object, there is an execute() method that allows actions to be performed on the Sqlite3 database. For example, the screen image shows the cursor connection and the ability through the connection to run a SELECT command. We’ve done quite a few SELECT commands in our course. Establish a connection, then use a cursor object. The execution of the SELECT moves the ‘result set’ from the query to a location where the data can be worked on by the Python program. 12/12/20 (C) 2020-2021 Highervista, LLC
  • 10. 10 USING FETCHONE() Now that a SELECT command was executed (a SELECT *), we can get one specific row by using the fetchone() command. With fetchone(), we can make changes to the one item that we ‘fetched.’ Any changes to the fetched record can be made to the particular record by Python, based on the decisions in the program. fetchone() method call Results of fetchone() method call to example database 12/12/20 (C) 2020-2021 Highervista, LLC
  • 11. 11 PYTHON Python can ‘seed’ (or set up) the connection and, within the cursor object, can also set up the particular methods that can be used to maintain the database. This avoids an individual who works daily with the company’s database from knowing the specifics about connection objects and methods. We leave this knowledge for the programmer to code, test and turn over to the user. 12/12/20 (C) 2020-2021 Highervista, LLC
  • 12. THE CURSOR AND METHODS WITHIN THE CURSOR SQL and Scripting Training 12/12/20 (C) 2020-2021 Highervista, LLC 12
  • 13. 13 USING THE FETCHALL() METHOD The fetchall() methods returns all records that can be worked on (modified) in the Python program. Depending on the database size, this can be a huge amount of data. For our example database, we have a smaller set of data. fetchall() method embedded within print command Result set 12/12/20 (C) 2020-2021 Highervista, LLC
  • 14. 14 PYTHON, EXAMPLE INSERT OF 1 RECORD Python can be used to insert records into a specific Sqlite3 table. Here’s an example where records are inserted into the consumers table by Python (first line). The second line prints the record. Using the cursor, do an INSERT into a Sqlite3 table on a previously connected database. Results of the INSERT printed out. 12/12/20 (C) 2020-2021 Highervista, LLC
  • 15. 15 PYTHON, EXAMPLE OF A LIST OF INSERTED RECORDS We can INSERT multiple records into the database using Python. Python used to set up multiple records that are INSERTed Print verification 12/12/20 (C) 2020-2021 Highervista, LLC
  • 16. 16 COMMIT The cursor that is established between the Python program and Sqlite3 helps facilitate the work between the programming language and the database. The changes are not made until the transactions are committed. The commit() method is part of the connection object that was first setup to connect the database to the programming language. The commit() method of the connection object makes the data ‘persistent’ in the database. 12/12/20 (C) 2020-2021 Highervista, LLC
  • 17. 17 VERIFYING THE COMMIT Once the Python program selects the data to be changed (modified or inserted), and the commit is completed successfully, you can use a tool like the DB Browser for SQLite to view the data on the database. 12/12/20 (C) 2020-2021 Highervista, LLC
  • 18. PYTHON/SQLITE SUMMARY SQL and Scripting Training 12/12/20 (C) 2020-2021 Highervista, LLC 18
  • 19. 19 PYTHON AND SQLITE SUMMARY You can connect an SQLite database to a Python program by using a connection object. The connection object sets up a cursor, where work by Python can be done on the database. The cursor has several ‘methods’ to get data from the database and to place data back into the database, once Python code is executed on the particular database. A commit is required to ensure that the changes are ‘persistent’ on the database. 12/12/20 (C) 2020-2021 Highervista, LLC
  • 20. 20 REFERENCE McFarland, R. (2020). Published Articles: Ron McFarland. Retrieved December 03, 2020, from https://medium.com/@highervista 12/12/20 (C) 2020-2021 Highervista, LLC
  • 22. 22 ABOUT THIS COURSE This course is distributed free. I use several sources. But importantly, I use the book noted on the next slide. If you are using these PowerPoints, please attribute Highervista, LLC and me (Ron McFarland). IN ADDITION, please attribute the author noted on the next slide, as the author’s textbook provides essential information for this course. Source: Microsoft Images
  • 23. 23 INTRODUCTION This course is offered to you free. HOWEVER, please purchase the following book, as it is a primary resource for this course. I do not make any $ from this course or this book. So, since a handful of good content is derived from the following text, please support this author! Title: SQL Quickstart Guide Author: Walter Shields Available: Amazon, B&N, and through ClydeBank media website at: https://www.clydebankmedia.com/books/programming- tech/sql-quickstart-guide