The SELECT statement is used to retrieve data from a database.
Basic Syntax:
SELECT column_name FROM table_name;
Example: Selecting student names and IDs from a students table:
SELECT student_id, name FROM students;
To select all columns, use *:
SELECT * FROM students;
Using Aliases (AS)
Aliases provide temporary names for columns or tables to improve readability.
Syntax:
SELECT column_name AS alias_name FROM table_name;
Example: Renaming columns in the result set:
SELECT product_name AS Product, price AS “Price (USD)” FROM products;
Table Aliases:
SELECT s.name FROM students AS s;
Filtering Data with Comparison Operators
Boolean Data Types & Comparison Operators
Boolean values (TRUE or FALSE) are used in conditions.
Comparison operators return boolean results and are used in WHERE clauses to filter data.
Operator
Description
Example
=
Equal to
WHERE age = 30
!= or <>
Not equal to
WHERE city != ‘London’
>
Greater than
WHERE salary > 50000
<
Less than
WHERE age < 40
>=
Greater than or equal to
WHERE score >= 90
<=
Less than or equal to
WHERE height <= 5.5
BETWEEN
Within a range (inclusive)
WHERE age BETWEEN 20 AND 30
IN
Matches multiple values
WHERE department IN (‘HR’, ‘Finance’)
LIKE
Pattern matching
WHERE name LIKE ‘J%’
Using WHERE to Filter Data
Filter by a specific condition:
SELECT * FROM employees WHERE age = 30;
Exclude certain values:
SELECT * FROM employees WHERE age != 30;
Filter using ranges (BETWEEN):
SELECT * FROM employees WHERE age BETWEEN 30 AND 40;
Check if a value exists in a set (IN):
SELECT * FROM employees WHERE name IN (‘Alice’, ‘Bob’);
Using LIKE for Pattern Matching
Find names that start with “J”:
SELECT * FROM students WHERE name LIKE ‘J%’;
Find names that end with “s”:
SELECT * FROM students WHERE name LIKE ‘%s’;
Find names that contain “ar” anywhere in them:
SELECT * FROM students WHERE name LIKE ‘%ar%’;
Key Takeaways
✔ SELECT retrieves data from a database. ✔ Aliases (AS) make query results more readable. ✔ Comparison operators allow filtering specific data. ✔ LIKE is used for pattern-based searches. ✔ BETWEEN, IN, and other conditions help refine queries.
Cyberwarfare involves using technology to attack a nation’s computer systems, causing disruption or physical damage. One major example is the Stuxnet malware, a sophisticated cyberweapon used to target Iran’s nuclear enrichment program.
Key Features of Stuxnet:
Spread primarily via USB drives to target air-gapped systems.
Used zero-day exploits to escalate privileges and install malware.
Installed drivers with stolen legitimate certificates.
Had modular coding, enabling updates while active.
Targeted Programmable Logic Controllers (PLCs) to manipulate industrial processes.
Focused on sabotage rather than data theft.
1.5.2 The Purpose of Cyberwarfare
Cyberwarfare is used to gain a strategic advantage over adversaries by disrupting critical infrastructure or stealing sensitive information.
1. Gaining Compromised Information and Defense Secrets
Nations engage in cyberwarfare to steal classified defense secrets and technological research.
Stolen sensitive data can be used for espionage or blackmailing government personnel.
2. Disrupting Infrastructure
Cyber attacks can target essential services like power grids, financial systems, or communication networks.
A power grid shutdown could lead to traffic congestion, halted commerce, emergency service failures, and loss of internet access.
Infrastructure attacks can destabilize a nation, causing economic harm and lowering public trust in the government.
Cyberwarfare represents a growing threat in modern conflicts, where attackers can cause significant disruption without physically entering a targeted country.
Traditional data is generated and maintained by organizations and includes:
Transactional Data: Buying/selling details, production activities, employment decisions.
Intellectual Property: Patents, trademarks, and trade secrets crucial for economic advantage.
Financial Data: Income statements, balance sheets, and cash flow statements.
1.2.1.2 Internet of Things (IoT) and Big Data
IoT refers to a network of connected devices that collect and share data. With the growth of IoT, Big Data has become a significant technological and business focus.
1.2.2 The Cube
The McCumber Cube is a cybersecurity model that evaluates security initiatives using three dimensions:
Foundational Principles:
Confidentiality: Prevents unauthorized access using encryption and authentication.
Integrity: Protects data from modifications using hash functions.
Availability: Ensures data access through maintenance, updates, and backups.
Data Protection in Different States:
Processing: Active use of data (e.g., database updates).
Storage: Data stored in memory or devices (e.g., hard drives).
Transmission: Data being transferred across networks.
Security Measures:
Awareness & Training: Educating users on security risks.
Technology: Firewalls, encryption, and security software.
Policies & Procedures: Incident response plans and security guidelines.
1.2.4 Is This for Real?
Phishing is a common cyber threat. Example:
In 2020, Razer experienced a data breach exposing 100,000 customer records due to a misconfigured cloud server.
Cybercriminals exploited this exposure for fraud and social engineering attacks.
1.2.5 Data Security Breaches
Persirai Botnet (2017)
Targeted over 1,000 IoT cameras.
Installed malware that ran undetected in memory.
Used hijacked cameras for DDoS attacks.
Equifax Breach (2017)
Attackers exploited a software vulnerability, exposing millions of customer records.
Fraudulent websites tricked customers into providing personal data.
Identity theft risks increased significantly.
1.2.6 Consequences of a Security Breach
Reputational Damage: Customers may lose trust and seek alternatives.
Vandalism: Hackers may alter websites or manipulate business information.
Theft: Stolen sensitive data can lead to identity fraud.
Loss of Revenue: Businesses may face operational shutdowns and financial penalties.
Intellectual Property Damage: Leaks of confidential documents and trade secrets can harm competitiveness.
Cybersecurity is the practice of protecting individuals, organizations, and governments from digital attacks by safeguarding networked systems and data from unauthorized use or harm.
Personal: Protect your identity, data, and devices.
Organisational: Everyone is responsible for protecting the organization’s reputation, data, and customers.
Government: Protection of digital information is critical for national security, economic stability, and citizen safety.
1.1.2 Protecting Your Personal Data
Personal data includes any information that can identify you and exists both online and offline.
Offline Identity: Information shared in daily life (name, age, address). Identity thieves can steal this data in person.
Online Identity: Includes usernames, aliases, and social profiles. Limit the amount of personal information shared online.
1.1.3 Your Online Identity
Choosing a secure username is crucial. Recommended examples: ✔ jdoe ✔ j.doe12 Avoid including full names, job roles, or birth years to protect privacy.
1.1.4 Your Data
Personal data includes names, social security numbers, birth details, and private messages. Cybercriminals use this information for fraud and impersonation.
Medical Records: Contain sensitive health data, including information from wearable fitness devices.
Education Records: Store academic details, contact info, and disciplinary records.
Employment & Financial Records: Include income, tax records, and banking details, which are valuable to hackers.
1.1.5 Where Is Your Data?
Once shared, data can be copied, stored, and distributed without control.
Photos shared with friends can be downloaded and re-shared globally.
Medical records may be accessed by insurance companies.
Store loyalty programs track purchasing behavior for targeted advertising.
1.1.6 Importance of Data Security
Every time personal data is collected or shared, security risks arise.
Laws exist to protect privacy, but it is essential to know where your data is stored and who has access.
1.1.7 Smart Devices
Computing devices not only store personal data but also generate new data about users.
Wearable Technology: Smartwatches and fitness trackers collect health data.
Online Services: Social media platforms monetise user data by sharing it with advertisers.
1.1.8 What Do Hackers Want?
Cybercriminals target personal data for financial gain.
Scams: Hackers impersonate family members to trick victims into sending money.
Frequent Flyer Theft: Cybercriminals have hacked airline accounts to book flights using stolen credentials.
1.1.9 Identity Theft
Cybercriminals use stolen data for long-term financial and personal exploitation.
Medical Theft: Stolen insurance details can be used for unauthorized medical procedures.
Banking Fraud: Identity thieves can file fake tax returns, take out loans, or damage credit scores.
1.1.10 Who Else Wants My Data?
It’s not just criminals who seek personal data:
Internet Service Providers (ISPs): Track and sometimes sell user data.
Advertisers: Monitor online activities for targeted ads.
Search Engines & Social Media: Collect and sell data, including search history, geolocation, and personal interests.
Key Takeaways:
Be cautious about sharing personal data online and offline.
Secure accounts with strong, anonymous usernames.
Understand how smart devices and online services collect and use personal data.
Recognise cybersecurity threats, including identity theft and financial fraud.
Stay informed about privacy laws and who has access to your data.
Currency Exchange Project (Intro blog coming soon!) is a small project created by a group of junior programmers aiming to build a Python application that integrates APIs, frameworks, and potentially other technologies. The goal here is to gain a better understanding of workflows commonly used in the ‘developer world’.
This project serves as a great learning opportunity for our future, including GitHub repositories and blog posts.
Before diving into our code, let’s first explain some key terminology. ʕっ•ᴥ•ʔっ
What is an API?
An API (Application Programming Interface) is a way for different software or services to communicate. It works like a waiter in a restaurant, taking requests, delivering them to the system, and returning a response.
For example, when using Google Maps, the app sends a request to Google’s API, which retrieves the necessary data and sends it back for display.
APIs exist in many forms, some follow established standards like HTTP, while others extend or build upon these, such as REST. Creating an API can involve anything from defining custom protocols and data structures to developing simple interfaces for utility libraries. In web applications, APIs commonly serve as the connection points between various underlying services.
In basic terms is API broadly refers to the code used to interact with a library or service. Typically, users only need to know how to use it, not how it operates internally
How do we import it?
First, let’s check what version of python we have, we do this by (in bash)
‘py –version’
We can see the output being ‘python 3.13.1’, basically meaning python3. Now knowing that we can do the next step
Since we are using python we have to ensure that we have installed some API tools within our systems. The command we do this is the following (this would depend on your device):
‘Py -m pip install requests’
You know it would work through a lot of output of ‘downloading’ stuff. If it doesn’t, you already have it, or your command is a little different due to a different system/ terminal. Google is your best friend there.
Now we need to create a virtual environment for our project. We do this by typing:
‘py -m venv venv’
The reason we do this is to ensure that each project has its own virtual environment, keeping it separate from other projects. Without a virtual environment, all dependencies would be installed globally, which can lead to conflicts if different projects require different versions of the same package. This can cause interference and potentially break everything.
With Linux users, installing packages globally can be risky because the operating system relies on Python internally. Modifying system-wide Python packages could disrupt essential system functions.
As a best practice, always create a virtual environment for every project, whether it’s a personal or group project. This keeps dependencies organised, prevents conflicts, and ensures a stable development environment.
Next let’s import the library at the top of the page. We do this by typing:
‘Import requests’
For our project, we would be importing JSON, making it easy to parse and extract the required currency rates. We do this by:
‘Import json’
Importing API
Now, we need to store the API in a variable so that we can call it easily instead of pasting that long link everywhere it’s needed. Since the project heavily relies on this API, it would be used everywhere!
currency_value_API – Stores the URL of an API that provides real-time currency exchange rates (in JSON format. In this case, it fetches exchange rates for EUR (Euro) against other currencies.)
Printing API
Now, let’s print the contents. First, I will fetch the data from the API, then convert it into JSON format, and finally print it to the console. Easy, innit!
This sends a request to the API to get the latest currency exchange rates.
The response is stored in all_currencies_response.
‘currency_data = all_currencies_response.json()’
The API sends data in text format, so .json() converts it into a Python dictionary.
This makes it easier to use and process in the program.
‘print(json.dumps(currency_data, indent=4))’
The data is formatted nicely using json.dumps(), adding indentation (spaces) for better readability.
print() then displays the currency exchange rates clearly.
This is the result:
We can see that using the json has formatted the code quite nicely and in a readable manner. And it wasn’t so hard to do it.
Next we might learn how to print/ search for specific currencies and have a better understanding of the first pull request of the project . Now let’s code ‘em all! ʕ -ᴥ•ʔ♡