Sqlite Intro Compucademy

Опубликовано: 24 Август 2019
на канале: Compucademy
149
1

A brief introduction to Sqlite, a lightweight database management system ideal for GCSE and A Level Computer Science study and use with Python.

You can check out our blog for articles on GCSE and A Level Computer Science and Python programming at https://compucademy.net/

SQL code is below. The DB Browser for Sqlite can be found here: https://sqlitebrowser.org/

```
CREATE TABLE cards (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
suit TEXT,
suit_symbol TEXT,
score INTEGER
);

INSERT INTO cards (name, suit, suit_symbol, score) VALUES

-- Spades
('A', 'spades', '♠', 1),
('2', 'spades', '♠', 2),
('3', 'spades', '♠', 3),
('4', 'spades', '♠', 4),
('5', 'spades', '♠', 5),
('6', 'spades', '♠', 6),
('7', 'spades', '♠', 7),
('8', 'spades', '♠', 8),
('9', 'spades', '♠', 9),
('10', 'spades', '♠', 10),
('J', 'spades', '♠', 11),
('Q', 'spades', '♠', 12),
('K', 'spades', '♠', 13),

-- Hearts
('A', 'hearts', '♥', 1),
('2', 'hearts', '♥', 2),
('3', 'hearts', '♥', 3),
('4', 'hearts', '♥', 4),
('5', 'hearts', '♥', 5),
('6', 'hearts', '♥', 6),
('7', 'hearts', '♥', 7),
('8', 'hearts', '♥', 8),
('9', 'hearts', '♥', 9),
('10', 'hearts', '♥', 10),
('J', 'hearts', '♥', 11),
('Q', 'hearts', '♥', 12),
('K', 'hearts', '♥', 13),

-- Clubs
('A', 'clubs', '♣', 1),
('2', 'clubs', '♣', 2),
('3', 'clubs', '♣', 3),
('4', 'clubs', '♣', 4),
('5', 'clubs', '♣', 5),
('6', 'clubs', '♣', 6),
('7', 'clubs', '♣', 7),
('8', 'clubs', '♣', 8),
('9', 'clubs', '♣', 9),
('10', 'clubs', '♣', 10),
('J', 'clubs', '♣', 11),
('Q', 'clubs', '♣', 12),
('K', 'clubs', '♣', 13),

-- Diamonds
('A', 'diamonds', '♦', 1),
('2', 'diamonds', '♦', 2),
('3', 'diamonds', '♦', 3),
('4', 'diamonds', '♦', 4),
('5', 'diamonds', '♦', 5),
('6', 'diamonds', '♦', 6),
('7', 'diamonds', '♦', 7),
('8', 'diamonds', '♦', 8),
('9', 'diamonds', '♦', 9),
('10', 'diamonds', '♦', 10),
('J', 'diamonds', '♦', 11),
('Q', 'diamonds', '♦', 12),
('K', 'diamonds', '♦', 13);
```