This is a repeat of the previous code but hopefully formatted better. Just copy and paste this into any Python editor and run it…
import sqlite3
db = sqlite3.connect(':memory:')
db.execute( '''
CREATE TABLE artist(
artistname TEXT PRIMARY KEY,
country TEXT,
genre TEXT
)
''')
db.execute( '''
INSERT INTO artist(artistname, country, genre)
VALUES
( 'ACDC' ,'Australia' ,'Rock'),
( 'Beatles','UK' ,'Pop'),
( 'Cramps' ,'USA' ,'Psychobilly'),
( 'Danzig' ,'USA' ,'Rock')
''')
results = db.execute('''
SELECT artistname, country
FROM artist
WHERE artist.genre = 'Rock'
''')
print ('Rock bands…')
for record in results:
print( f'The band {record[0]} is from {record[1]}')
db.close()