Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Monday, September 21, 2026

What Is Python?

// programming

What Is Python?

Python is a high-level, general-purpose programming language known for readable syntax and a large ecosystem of libraries. It is widely used for automation, data processing, web development, artificial intelligence, APIs and many other programming tasks.

// definition

Python is a programming language

Python is a general-purpose programming language used to express instructions that computers can execute.

It is designed around relatively clear and concise syntax, allowing many programs to be expressed with comparatively little code.

Python can be used for small scripts as well as much larger software systems.

// hello world

A Python program can be extremely simple

print("Hello, world!")

The print() function sends the text to the program's output.

Hello, world!
// files

Python source files normally use .py

hello.py automation.py data_cleaner.py api_client.py

These files contain Python source code written as plain text.

// variables

Python can store values in variables

name = "Freelance Coder" price = 25.50 quantity = 4 active = True

The variable name provides a way for later instructions to refer to the stored object.

// data types

Python has many built-in data types

Type Example
str "Hello"
int 42
float 3.14
bool True
list [1, 2, 3]
dict {"name": "Tiago"}
tuple (1, 2)
set {1, 2, 3}
NoneType None
// dynamic typing

Python is dynamically typed

A variable name does not have to be declared with a fixed type before it is used.

x = 10 x = "hello"

In this example, the name x first refers to an integer and later refers to a string.

The objects still have types. Dynamic typing means Python determines and checks those types at runtime rather than requiring every variable declaration to specify one in advance.

// operators

Python can perform calculations

a = 10 b = 3 a + b a - b a * b a / b a ** b a % b

These operators perform addition, subtraction, multiplication, division, exponentiation and remainder operations.

// lists

Lists store ordered collections

languages = [ "Python", "JavaScript", "PHP" ]

Python list indexes begin at zero.

languages[0] # "Python"
// dictionaries

Dictionaries store key-value relationships

product = { "name": "Keyboard", "price": 39.99, "stock": 12 }

Individual values can be retrieved using their keys.

product["price"] # 39.99
// conditions

Python can make decisions

age = 20 if age >= 18: print("Adult") else: print("Under 18")

The program follows different instructions depending on whether the condition is true or false.

// indentation

Indentation is part of Python syntax

Many programming languages use braces to group blocks of instructions.

Python uses indentation.

if temperature > 20: print("Warm") print("Open the window") print("Finished")

The two indented instructions belong to the if block.

Whitespace can therefore affect program meaning. Indentation is not merely visual formatting in Python.

// loops

Loops repeat instructions

for number in [1, 2, 3]: print(number)

Output:

1 2 3
// range

range() is useful for repeated operations

for i in range(5): print(i)

This produces:

0 1 2 3 4
// functions

Functions package reusable behaviour

def add(a, b): return a + b result = add(5, 7) print(result)

Output:

12

Functions help divide larger programs into smaller, reusable pieces.

// classes

Python supports object-oriented programming

class Product: def __init__(self, name, price): self.name = name self.price = price product = Product( "Keyboard", 39.99 )

Classes can define objects that combine data and behaviour.

// modules

Programs can be divided into modules

Python code stored in separate files can be imported and reused.

import math result = math.sqrt(25) print(result)

Output:

5.0
// standard library

Python includes a large standard library

A Python installation includes modules for many common programming tasks.

Files JSON CSV SQLite Dates Regular Expressions Networking ZIP Files
// packages

Additional libraries can be installed

Python has a very large ecosystem of third-party packages.

Packages are commonly installed using pip.

pip install requests

The package can then be imported into a Python program.

import requests
// environments

Projects can use virtual environments

Different projects may depend on different package versions.

A virtual environment creates an isolated Python environment for a project.

python -m venv .venv
Project A ↓ Environment A ↓ Its packages Project B ↓ Environment B ↓ Different packages
// file handling

Python can read and write files

with open( "example.txt", "r", encoding="utf-8" ) as file: text = file.read() print(text)

This makes Python useful for processing large numbers of files automatically.

// csv

Python can process CSV data

import csv with open( "customers.csv", encoding="utf-8", newline="" ) as file: rows = csv.reader(file) for row in rows: print(row)

CSV processing is useful for spreadsheets, exports, reports and data cleaning.

// json

Python works naturally with JSON

import json text = '{"name": "Alice", "active": true}' data = json.loads(text) print(data["name"])

Output:

Alice
// databases

Python can communicate with databases

Python's standard library includes support for SQLite, and third-party packages can connect to many other database systems.

Python ↓ SQL ↓ Database ↓ Rows of data
SQLite PostgreSQL MySQL SQL Server
// sqlite example

Python can create a SQLite database

import sqlite3 connection = sqlite3.connect( "products.db" ) cursor = connection.cursor() cursor.execute(""" CREATE TABLE IF NOT EXISTS products ( id INTEGER PRIMARY KEY, name TEXT, price REAL ) """) connection.commit() connection.close()
// apis

Python can communicate with APIs

A Python application can send HTTP requests and process the returned information.

Python program ↓ HTTP request ↓ API ↓ JSON response ↓ Python data

A third-party library such as requests is commonly used for this.

import requests response = requests.get( "https://api.example.com/products" ) data = response.json()
// automation

Python is particularly useful for automation

A Python script can perform repetitive technical tasks without someone manually completing each step.

Read files ↓ Clean data ↓ Call API ↓ Update database ↓ Create spreadsheet ↓ Generate report
// spreadsheets

Python can work with Excel files

Libraries such as openpyxl can read, create and modify .xlsx workbooks.

from openpyxl import Workbook workbook = Workbook() sheet = workbook.active sheet["A1"] = "Product" sheet["B1"] = "Price" workbook.save( "products.xlsx" )

This can automate spreadsheet reporting and data processing.

// data

Python is widely used for data work

Data Cleaning Data Analysis Statistics Visualisation Spreadsheets Databases

Libraries such as NumPy and pandas provide additional tools for numerical and tabular data processing.

// artificial intelligence

Python is widely used in AI and machine learning

Many machine-learning and artificial-intelligence libraries provide Python interfaces.

Machine Learning Neural Networks Natural Language Processing Computer Vision

Python's role here is strengthened by its extensive scientific and data-processing ecosystem.

// web development

Python can run web applications

Python can execute on a server and generate website responses.

Browser ↓ HTTP request ↓ Python web application ↓ Database / APIs ↓ HTTP response ↓ Browser

Python web frameworks include technologies such as Django, Flask and FastAPI.

// python vs javascript

Python and JavaScript often run in different places

Python JavaScript
Commonly runs on servers or computers Runs directly in web browsers
Strong data and automation ecosystem Core language of browser interactivity
Can build back-end web services Can build front-end and back-end applications

Both languages are general-purpose enough to overlap in many areas.

// execution

How does Python code actually run?

The most widely used Python implementation is CPython.

In simplified form, CPython processes source code, compiles it into Python bytecode and executes that bytecode using its interpreter.

Python source code ↓ Compilation ↓ Python bytecode ↓ Python virtual machine ↓ Program executes

Calling Python simply "interpreted" is useful but incomplete. Python implementations can use different execution techniques. CPython normally compiles source code to bytecode before executing it.

// interactive shell

Python can also be used interactively

Python provides an interactive environment where instructions can be entered one at a time.

>>> 2 + 3 5 >>> "hello".upper() 'HELLO'

This makes it convenient for experimentation, calculations and testing small pieces of code.

// readability

Python emphasises readable syntax

Compare the structure of a simple condition:

if balance > 0: print("Positive balance")

Keywords such as if, for, in, def and return make much Python code relatively close to structured written instructions.

// uses

What is Python used for?

Automation

Repetitive computer tasks can be scripted.

Data

Files, spreadsheets and databases can be processed.

APIs

Programs can communicate with external services.

Web Development

Python can power server-side web applications.

AI

Python is widely used with machine-learning tools.

Scientific Computing

Numerical and scientific libraries support research and technical computing.

// practical example

One script can connect several technologies

CSV file ↓ Python ↓ Clean data ↓ SQLite database ↓ API request ↓ Create XLSX report ↓ ZIP output files

This ability to connect different formats, systems and services is one reason Python is particularly useful for automation and data-management work.

// mental model

The simplest way to think about Python

Data ↓ Python instructions ↓ Logic + calculations ↓ Files / APIs / databases ↓ Useful result

Python provides a language for describing the operations a computer should perform.

// summary

Instructions become automation.

Python is a high-level, general-purpose programming language with readable syntax and a large software ecosystem. It can work with files, spreadsheets, databases, APIs and websites, and is widely used for automation, data processing, scientific computing, artificial intelligence and software development.

What Is a ZIP File?

// file formats

What Is a ZIP File?

A ZIP file is an archive file that can combine multiple files and folders into a single package. It can also compress the data inside, reducing the amount of storage space required and making collections of files easier to transfer.

// definition

ZIP is an archive format

A ZIP file is an archive that can contain one or more files and directories.

The contents can be stored together inside a single file ending in the .zip extension.

ZIP also supports lossless compression, allowing many types of data to be stored using fewer bytes.

// example

Several files can become one archive

Suppose a folder contains:

project/ │ ├── index.html ├── styles.css ├── script.js └── logo.png

The entire folder could be packaged as:

project.zip

Instead of sending four separate files and their folder structure, you can send a single archive.

// archive

ZIP preserves files and folders together

A ZIP archive can preserve directory structure.

website.zip │ ├── index.html │ ├── css/ │ └── styles.css │ ├── js/ │ └── app.js │ └── images/ └── logo.png

When the archive is extracted, the original folder structure can be recreated.

// compression

ZIP files can compress data

Compression attempts to represent the same information using fewer bytes.

Original files ↓ Compression ↓ Smaller ZIP archive

The amount saved depends heavily on the type of data being compressed.

// lossless

ZIP compression is lossless

Lossless compression means the original information can be reconstructed exactly when the archive is decompressed.

Original file ↓ Compress ↓ ZIP data ↓ Extract ↓ Original file restored

No content needs to be deliberately discarded. This is different from lossy formats that may remove information to achieve smaller file sizes.

// file size

Not every file becomes much smaller

Text-based files often compress very effectively because they can contain repeated patterns.

TXT CSV XML HTML JSON

Files that are already compressed may shrink very little.

JPEG MP3 MP4 PNG

In some cases, placing already compressed data inside a ZIP archive may produce almost no size reduction.

// storage

ZIP can also store files without compression

A ZIP archive does not require every file inside it to be compressed.

Entries can also be stored directly while still benefiting from the archive structure.

ZIP archive │ ├── file1.txt → compressed ├── photo.jpg → stored └── video.mp4 → stored
// extraction

What does "extract" mean?

Extracting a ZIP file means taking files out of the archive and restoring them as ordinary files and folders.

project.zip ↓ Extract ↓ project/ ├── index.html ├── styles.css └── script.js

The ZIP archive itself can remain unchanged after extraction.

// creating

What does "zip" a folder mean?

To zip files means to package them inside a ZIP archive.

Folder ↓ Create ZIP archive ↓ folder.zip

Operating systems such as Windows and macOS include built-in tools for creating and extracting ZIP archives.

// internal structure

A ZIP file contains multiple file records

Internally, ZIP stores information about the files inside the archive.

This can include:

File Names Folder Paths Compressed Data File Sizes Checksums Timestamps
// directory

ZIP files contain a central directory

A ZIP archive normally contains a central directory describing the entries stored inside it.

ZIP archive │ ├── File data ├── File data ├── File data │ └── Central directory ├── file names ├── locations ├── sizes └── metadata

Software can use this information to find and list the archive's contents.

// integrity

ZIP files can detect some forms of corruption

ZIP entries commonly include a CRC-32 checksum.

The checksum can be used to check whether extracted data matches the data expected by the archive.

Stored checksum ↓ Extracted file ↓ Calculate checksum ↓ Compare values
// encryption

ZIP archives can be password-protected

Some ZIP tools support encryption so that the archive contents cannot be read without the required password.

Password protection and compression are different things. Compression reduces or packages data. Encryption is intended to protect data from unauthorised access.

// container format

ZIP is also used as a container for other file formats

Some file formats are actually specialised ZIP packages.

Format What it contains
.xlsx Excel workbook XML and supporting files
.docx Word document XML and supporting files
.pptx PowerPoint XML and supporting files

These formats use ZIP as the underlying package containing multiple structured files.

// xlsx example

An .xlsx file is a specialised ZIP package

workbook.xlsx ↓ ZIP package ↓ xl/ ├── workbook.xml ├── styles.xml └── worksheets/ └── sheet1.xml

This is why renaming a copy of an .xlsx file to .zip can allow ZIP software to inspect its internal structure.

// zip vs folder

A ZIP archive is not the same as a normal folder

Folder ZIP archive
Directory on a file system Single archive file
Contains files directly Packages entries inside the archive
No compression by itself Can compress contained files
Easy to edit directly Usually extracted or modified with archive software
// archive formats

ZIP is one of several archive formats

ZIP RAR 7Z TAR GZIP

These formats have different features, compression methods and levels of software support.

ZIP is particularly widespread because support is built into many operating systems and applications.

// programming

Software can create ZIP files automatically

Programming languages can create, inspect and extract ZIP archives.

Python PHP JavaScript Java C#
// python example

Python can create ZIP archives

import zipfile with zipfile.ZipFile( "project.zip", "w", zipfile.ZIP_DEFLATED ) as archive: archive.write("index.html") archive.write("styles.css")

The program creates an archive and adds files to it.

// automation

ZIP files are useful in automated workflows

Generate files ↓ Create ZIP ↓ Upload archive ↓ Send to customer ↓ Customer extracts files

This makes ZIP useful for exports, backups, downloadable packages and batch processing.

// backups

ZIP files are commonly used for backups

A group of related files can be bundled into one archive:

website-backup.zip │ ├── html/ ├── css/ ├── images/ ├── scripts/ └── data/

This makes the collection easier to copy, store and transfer.

// transfer

ZIP files make collections easier to send

Instead of attaching twenty separate files to a message, they can be placed inside one archive.

20 files ↓ project.zip ↓ 1 attachment
// security

ZIP files should still be treated carefully

A ZIP archive can contain almost any type of file, including executable programs and scripts.

Receiving a file inside a ZIP archive does not make that file automatically safe.

Only extract and run files from sources you trust. An archive is simply a container and does not guarantee that its contents are harmless.

// uses

What are ZIP files used for?

File Transfer Compression Backups Software Downloads Website Files Data Exports Document Packages Automation Archiving
// mental model

The simplest way to think about a ZIP file

Files + folders ↓ Package together ↓ Optional compression ↓ archive.zip ↓ Transfer or store ↓ Extract ↓ Original files + folders
// summary

Many files. One package.

A ZIP file is an archive format that can package multiple files and folders into a single file. ZIP supports lossless compression, preserves directory structures and is widely used for transfers, backups, downloads and software packaging. Some formats such as XLSX, DOCX and PPTX also use ZIP internally as their container format.

What Is an API?

// software communication

What Is an API?

An API is an interface that allows one piece of software to interact with another. It defines how requests can be made, what information can be supplied and what results can be returned.

// definition

API means Application Programming Interface

API stands for Application Programming Interface.

An API provides a defined way for software systems, applications or components to communicate.

Instead of one program needing to understand the internal code of another program, it can communicate through the interface the API exposes.

// simple idea

An API is a controlled interface

Application A ↓ API ↓ Application B

Application A does not necessarily need access to the internal workings of Application B.

It only needs to know how to use the API correctly.

// example

Imagine a weather application

A website wants to display the current temperature in London.

Instead of measuring the weather itself, it can request information from a weather service.

Website ↓ Weather API ↓ Weather service ↓ Temperature data ↓ Website

The website can then display the information returned by the API.

// request + response

Many APIs use requests and responses

A client sends a request.

The API processes the request and sends a response.

Client ↓ Request ↓ API ↓ Processing ↓ Response ↓ Client

This request-response model is extremely common in web APIs.

// web api

Web APIs communicate over networks

Many modern APIs are accessed using HTTP or HTTPS, the same fundamental protocols used by websites.

https://api.example.com/products

Software can send an HTTP request to this address and receive structured information in return.

// endpoint

What is an API endpoint?

An endpoint is a particular location exposed by an API for performing an operation or accessing a resource.

/products /products/42 /customers /orders

Different endpoints can provide access to different types of information or functionality.

// http methods

HTTP methods describe the intended operation

Method Common purpose
GET Retrieve information
POST Submit or create information
PUT Replace or update a resource
PATCH Partially update a resource
DELETE Remove a resource

The exact meaning depends on the API's design.

// get

GET can retrieve information

GET /products/42

The API might return:

{ "id": 42, "name": "Keyboard", "price": 39.99 }
// post

POST can send information

A client might create a new customer by sending:

POST /customers

with data such as:

{ "name": "Alice", "email": "alice@example.com" }

The server can validate the information, store it and return a response.

// json

APIs commonly use JSON

JSON is a convenient format for exchanging structured information between software systems.

{ "customer": { "id": 101, "name": "Alice", "active": true } }

A client can parse this data and use the individual values in its own application.

// data formats

APIs do not have to use JSON

Depending on the system, an API may exchange data using:

JSON XML HTML Plain Text Binary Data
// parameters

Requests can include parameters

Parameters allow the client to specify what it wants.

GET /weather?city=London

Here:

city=London

provides additional information to the API.

// headers

HTTP requests can contain headers

Headers carry metadata about a request or response.

Content-Type: application/json Authorization: Bearer TOKEN

Headers can specify things such as data format, authentication information and caching behaviour.

// authentication

Many APIs require authentication

An API may need to know which application or user is making a request.

Common approaches include:

API Keys Access Tokens OAuth Sessions Signed Requests

API credentials should be protected. Private keys and tokens should not normally be exposed publicly in website source code or public repositories.

// api key

What is an API key?

An API key is a value that can identify an application or account when making API requests.

API-Key: abc123...

The service can use the key to determine who is making the request and which permissions or usage limits apply.

// status codes

Web APIs often return HTTP status codes

Code General meaning
200 Request succeeded
201 Resource created
400 Problem with the request
401 Authentication required or invalid
403 Request understood but not permitted
404 Resource not found
429 Too many requests
500 Server-side error
// javascript

JavaScript can call web APIs

fetch("https://api.example.com/products") .then(response => response.json()) .then(data => { console.log(data); });

The browser sends the request, receives the response and converts the JSON into JavaScript data.

// server-side code

Server-side software can also use APIs

PHP, Python, JavaScript, Java, C# and many other languages can communicate with APIs.

Application ↓ API request ↓ External service ↓ API response ↓ Application

APIs allow systems written in completely different programming languages to work together.

// database

An API can sit between an application and a database

Website ↓ API ↓ Server application ↓ Database

The website does not need direct access to the database.

Instead, the API exposes specific operations while the server controls how the underlying data is accessed.

// controlled access

APIs can control what software is allowed to do

An application may be allowed to:

Read Products Create Orders Update Profiles Upload Files

while being prevented from directly accessing internal systems or performing unauthorised operations.

// rate limits

APIs can limit how frequently they are used

A service might allow:

1,000 requests per day

or:

100 requests per minute

These restrictions are called rate limits.

// rest

What is a REST API?

REST stands for Representational State Transfer.

It describes an architectural style for designing networked systems.

APIs described as RESTful commonly organise operations around resources and use HTTP methods such as GET, POST, PUT, PATCH and DELETE.

API and REST API are not synonyms. REST is one approach to API design. APIs can use many other architectures and protocols.

// other api styles

APIs can use different technologies

REST GraphQL SOAP RPC WebSockets

The best approach depends on the systems involved and what they need to communicate.

// important distinction

Not every API is a web API

The term API is broader than internet services.

Programming languages, operating systems, libraries and software frameworks can all expose APIs.

Browser API Operating system API Database API JavaScript API Web API Library API

In each case, the API defines how another piece of software can interact with the system.

// examples

What can APIs connect?

Payments

A website can communicate with a payment service.

Maps

An application can retrieve maps or location data.

AI

Software can send prompts or data to an AI service.

Email

Applications can send or manage messages through email services.

Accounting

Business systems can exchange invoices, transactions or customer information.

Automation

One service can trigger actions in another system.

// automation

APIs make automation possible

Suppose a customer submits an online order.

Order received ↓ Payment API ↓ Database ↓ Email API ↓ Accounting API ↓ Order completed

Multiple systems can communicate automatically without someone manually copying the information between them.

// contract

An API behaves like a software contract

The API documentation defines how another program is expected to interact with the system.

It might specify:

Endpoints Methods Parameters Authentication Data Formats Responses Errors Rate Limits

As long as both systems follow the agreed interface, their internal implementations can often change without requiring the other system to understand those details.

// advantages

Why are APIs so useful?

Integration

Different software systems can work together.

Automation

Information can move between systems automatically.

Abstraction

Applications can use functionality without knowing every internal implementation detail.

Reuse

The same service can support websites, mobile apps, internal tools and other software.

// mental model

The simplest way to think about an API

Your software ↓ "Please do this" ↓ API ↓ Other software ↓ Result ↓ Your software

The API defines the rules for that conversation.

// summary

Software talking to software.

An API is an Application Programming Interface: a defined way for software systems to interact. APIs can expose data and functionality through requests, responses, endpoints and documented rules, making them fundamental to integrations, automation, websites, applications and modern software systems.

What Is SQLite?

// databases

What Is SQLite?

SQLite is a lightweight relational database system that stores an entire database in a file. Unlike many database systems, it does not require a separate database server running in the background.

// definition

SQLite is an embedded relational database

SQLite is a relational database management system designed to be embedded directly inside applications.

A complete SQLite database is commonly stored in a single file on disk.

Applications interact with that file using SQL commands such as SELECT, INSERT, UPDATE and DELETE.

// simple idea

A database can be just one file

A SQLite database might look like this:

customers.db

Inside that file could be several tables:

customers orders products payments

The application can open the database file and query those tables directly.

// serverless

SQLite does not need a separate database server

Systems such as MySQL and PostgreSQL normally run as separate database server processes.

Applications connect to those servers over a local connection or network connection.

SQLite works differently.

Application ↓ SQLite library ↓ database.db

The application accesses the database through the SQLite library rather than contacting a separate database server.

// sql

SQLite uses SQL

SQL stands for Structured Query Language.

SQL is used to create, read, update and delete data stored in relational databases.

SELECT * FROM customers;

This query asks SQLite to return all rows from the customers table.

// tables

SQLite stores data in tables

A customer table might contain:

id name email
1 Alice alice@example.com
2 Ben ben@example.com
3 Carla carla@example.com

Each row represents a record, while each column represents a particular type of information.

// create table

Tables can be created with SQL

CREATE TABLE customers ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, email TEXT );

This creates a table containing three columns:

id name email
// insert

Data can be inserted

INSERT INTO customers ( name, email ) VALUES ( 'Alice', 'alice@example.com' );

This adds a new row to the customers table.

// select

Data can be retrieved

SELECT name, email FROM customers;

A condition can also be added:

SELECT * FROM customers WHERE id = 1;

This retrieves the customer whose ID is 1.

// update

Existing data can be changed

UPDATE customers SET email = 'alice.new@example.com' WHERE id = 1;

This changes the email address associated with the selected row.

// delete

Rows can be deleted

DELETE FROM customers WHERE id = 1;

The matching row is removed from the table.

// crud

These operations are often called CRUD

Create

Add new records to the database.

Read

Retrieve existing information.

Update

Change existing records.

Delete

Remove records from the database.

// relational

SQLite is a relational database

Relational databases can connect information stored across different tables.

For example:

customers id | name 1 | Alice orders id | customer_id | total 1001 | 1 | 49.99 1002 | 1 | 18.50

The customer_id value connects the orders to Alice's customer record.

// joins

SQL can combine related tables

SELECT customers.name, orders.total FROM customers JOIN orders ON customers.id = orders.customer_id;

The database can use the relationship between the tables to combine the relevant information.

// files

SQLite databases can use different file extensions

You may encounter files such as:

data.db database.sqlite app.sqlite3 customers.db

The extension does not fundamentally determine whether the file is a SQLite database. It is mainly a naming convention.

// storage classes

SQLite can store several kinds of values

Storage class Purpose
NULL No value
INTEGER Whole numbers
REAL Floating-point numbers
TEXT Text strings
BLOB Binary data
// embedded

SQLite is often embedded inside applications

Software can include SQLite as part of the application itself.

The user may never even realise that a SQLite database is being used.

Desktop Apps Mobile Apps Browsers Local Tools Development Testing
// portable

SQLite databases are highly portable

Because a database can be stored in a single file, it can be straightforward to copy, back up or move.

project/ │ ├── app.py ├── database.db └── settings.json

The database can sit directly alongside the application files.

// sqlite vs csv

SQLite is very different from CSV

CSV SQLite
Plain-text file Database file
Usually one table Can contain many tables
No SQL engine Supports SQL queries
Limited relationships Relational structure
Simple data exchange Application data storage
// sqlite vs mysql

SQLite and MySQL use different architectures

SQLite MySQL
Embedded database Database server
Database commonly stored in one file Server manages database storage
No separate server required Requires database server software
Excellent for local and embedded use Common for networked applications
// sqlite vs server database

SQLite is not designed for every database workload

SQLite is extremely useful when simplicity and local storage are important.

A dedicated database server such as PostgreSQL or MySQL may be more appropriate when an application requires many simultaneous writers, centralised access, extensive server administration or large multi-user workloads.

SQLite is not simply a smaller MySQL. Its architecture is deliberately different. It is designed to provide a database engine directly inside an application.

// transactions

SQLite supports transactions

A transaction allows several database operations to be treated as one logical unit.

BEGIN; UPDATE accounts SET balance = balance - 50 WHERE id = 1; UPDATE accounts SET balance = balance + 50 WHERE id = 2; COMMIT;

Transactions help protect data from being left in an incomplete state if an operation fails.

// reliability

SQLite supports ACID transactions

Atomicity

A transaction is completed as a unit or rolled back.

Consistency

Database rules can help preserve valid states.

Isolation

Transactions are managed to avoid unsafe interference.

Durability

Committed changes are designed to survive failures.

// indexes

Indexes can improve query performance

CREATE INDEX idx_customer_email ON customers(email);

An index can allow the database to find certain values more efficiently instead of examining every row.

// programming

Many programming languages can use SQLite

Python PHP JavaScript C C++ Java C# Swift
// example with python

SQLite can be used from application code

For example, Python includes support for SQLite:

import sqlite3 connection = sqlite3.connect("customers.db") cursor = connection.cursor() cursor.execute( "SELECT * FROM customers" ) rows = cursor.fetchall() connection.close()

The program opens the database file, executes a query and retrieves the results.

// uses

What is SQLite used for?

Mobile Apps Desktop Software Local Data Application Settings Prototypes Testing Small Websites Data Analysis Embedded Systems Offline Applications
// advantages

Why is SQLite useful?

Simple

No separate database server needs to be configured.

Portable

An entire database can commonly be stored in one file.

Lightweight

The database engine can be embedded directly inside an application.

Powerful

It still provides SQL, transactions, indexes, relationships and many database features.

// important distinction

A SQLite database is more than an ordinary data file

A CSV file stores rows of text.

A JSON file stores structured text.

A SQLite file contains a database managed by an actual database engine.

CSV → data file JSON → structured data file SQLite → database stored in a file

That distinction is important.

// summary

A database inside one file.

SQLite is an embedded relational database system that provides SQL, tables, relationships, transactions and indexes without requiring a separate database server. Its simplicity and portability make it useful for mobile apps, desktop software, local tools, prototypes and many other applications.

What Is an IP Address?

// networking What Is an IP Address? An IP address is a numerical address used t...