Cassandra#

  • A production grade NoSQL database.

  • Can be distributed across servers, nodes, etc.

  • Replication of database is supported for high degree of redundancy and speed.

  • Uses CQL, a subset of SQL for querying.

  • Works seamlesly together with Spark and its corresponding distributed structure.

  • Installation of Cassandra is explained in the Installation chapter.

Spinning up a local Cassandra instance#

In a terminal, first time:
docker run --name my_cassandra -p 9042:9042 cassandra:latest
… and later:
docker start my_cassandra

… or in Docker Desktop:

  • Run the cassandra docker image with optional settings, opening 9042 port and setting a name.

  • Later, simply run the container with the name you chose.

https://github.com/khliland/IND320/blob/main/D2Dbook/images/Docker_images.png?raw=TRUE https://github.com/khliland/IND320/blob/main/D2Dbook/images/Docker_containers.png?raw=TRUE

Connect to the Cassandra cluster from Python.#

# Connecting to Cassandra
from cassandra.cluster import Cluster
cluster = Cluster(['localhost'], port=9042)
session = cluster.connect()

Keyspace#

  • In Cassandra database tables are stored in keyspaces (basically a distributed database).

  • These have parameters controlling their distribution on nodes/servers and redundancy.

  • We will use the simplest form locally.

# Set up new keyspace (first time only)
#                                              name of keyspace                        replication strategy           replication factor
session.execute("CREATE KEYSPACE IF NOT EXISTS my_first_keyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };")
<cassandra.cluster.ResultSet at 0x1075bd5b0>

Create a table#

  • IF NOT EXISTS makes sure we do not overwrite existing tables

# Create a new table (first time only)
session.set_keyspace('my_first_keyspace')
session.execute("DROP TABLE IF EXISTS my_first_keyspace.my_first_table;") # Starting from scratch every time
session.execute("CREATE TABLE IF NOT EXISTS my_first_table (ind int PRIMARY KEY, company text, model text);")
<cassandra.cluster.ResultSet at 0x107e575f0>

Inserting and reading data#

# Insert some data (ind is the primary key, must be unique)
session.execute("INSERT INTO my_first_table (ind, company, model) VALUES (1, 'Tesla', 'Model S');")
session.execute("INSERT INTO my_first_table (ind, company, model) VALUES (2, 'Tesla', 'Model 3');")
session.execute("INSERT INTO my_first_table (ind, company, model) VALUES (3, 'Polestar', '3');")
<cassandra.cluster.ResultSet at 0x107e641d0>
# Query the data
rows = session.execute("SELECT * FROM my_first_table;")
for i in rows:
    print(i)
Row(ind=1, company='Tesla', model='Model S')
Row(ind=2, company='Tesla', model='Model 3')
Row(ind=3, company='Polestar', model='3')

Case sensitivity#

  • Cassandra is by default case insensitive in column names.

  • To use column names with capital letters, use double quotation marks both when creating tables and when inserting data.

  • The effect of insensitivity may be surprising.

    • Look carefully at the use of quotation marks and error message below.

session.set_keyspace('my_first_keyspace')
session.execute("DROP TABLE IF EXISTS my_first_keyspace.case_insensitive;") # Starting from scratch every time
session.execute("CREATE TABLE IF NOT EXISTS case_insensitive (Capital int PRIMARY KEY, Letters text, Everywhere text);")
session.execute("DROP TABLE IF EXISTS my_first_keyspace.case_sensitive;") # Starting from scratch every time
session.execute("CREATE TABLE IF NOT EXISTS case_sensitive (\"Capital\" int PRIMARY KEY, \"Letters\" text, \"Everywhere\" text);")
<cassandra.cluster.ResultSet at 0x107c46630>
session.execute("INSERT INTO case_insensitive (Capital, Letters, Everywhere) VALUES (1, 'Tesla', 'Model S');")
<cassandra.cluster.ResultSet at 0x1075bdaf0>
session.execute("INSERT INTO case_sensitive (Capital, Letters, Everywhere) VALUES (1, 'Tesla', 'Model S');")
---------------------------------------------------------------------------
InvalidRequest                            Traceback (most recent call last)
Cell In[8], line 1
----> 1 session.execute("INSERT INTO case_sensitive (Capital, Letters, Everywhere) VALUES (1, 'Tesla', 'Model S');")

File ~/miniforge3/envs/ind320_25/lib/python3.12/site-packages/cassandra/cluster.py:2677, in Session.execute(self, query, parameters, timeout, trace, custom_payload, execution_profile, paging_state, host, execute_as)
   2634 def execute(self, query, parameters=None, timeout=_NOT_SET, trace=False,
   2635             custom_payload=None, execution_profile=EXEC_PROFILE_DEFAULT,
   2636             paging_state=None, host=None, execute_as=None):
   2637     """
   2638     Execute the given query and synchronously wait for the response.
   2639 
   (...)   2674     on a DSE cluster.
   2675     """
-> 2677     return self.execute_async(query, parameters, trace, custom_payload, timeout, execution_profile, paging_state, host, execute_as).result()

File ~/miniforge3/envs/ind320_25/lib/python3.12/site-packages/cassandra/cluster.py:4956, in ResponseFuture.result(self)
   4954     return ResultSet(self, self._final_result)
   4955 else:
-> 4956     raise self._final_exception

InvalidRequest: Error from server: code=2200 [Invalid query] message="Undefined column name capital in table my_first_keyspace.case_sensitive"
session.execute("INSERT INTO case_sensitive (\"Capital\", \"Letters\", \"Everywhere\") VALUES (1, 'Tesla', 'Model S');")
<cassandra.cluster.ResultSet at 0x107e55430>
# Query the data
rows = session.execute("SELECT * FROM case_insensitive;")
for i in rows:
    print(i)
rows = session.execute("SELECT * FROM case_sensitive;")
for i in rows:
    print(i)
Row(capital=1, everywhere='Model S', letters='Tesla')
Row(Capital=1, Everywhere='Model S', Letters='Tesla')

Asyncronous writing#

  • If your application is very data intensive, waiting for a response is not productive.

  • Writing asyncronously sends the data but does not pause for reply.

session.execute_async("INSERT INTO my_first_table (ind, company, model) VALUES (5, 'Volkswagen', 'ID.3');")
<ResponseFuture: query='<SimpleStatement query="INSERT INTO my_first_table (ind, company, model) VALUES (5, 'Volkswagen', 'ID.3');", consistency=Not Set>' request_id=63 result=(no result yet) exception=None coordinator_host=None>
# Query the data
rows = session.execute("SELECT * FROM my_first_table;")
for i in rows:
    print(i)
Row(ind=5, company='Volkswagen', model='ID.3')
Row(ind=1, company='Tesla', model='Model S')
Row(ind=2, company='Tesla', model='Model 3')
Row(ind=3, company='Polestar', model='3')
# More specific query
prepared_statement = session.prepare("SELECT * FROM my_first_table WHERE company=? ALLOW FILTERING;")
teslas = session.execute(prepared_statement, ['Tesla'])
for i in teslas:
    print(i)
Row(ind=1, company='Tesla', model='Model S')
Row(ind=2, company='Tesla', model='Model 3')

Cassandra filtering#

Cassandra is inherently a distributed production database. Selecting as above may require downloading all data from a node, then filtering based on the WHERE part (only PRIMARY KEYs are centrally known). Solutions:

  • If the table is small or most of the data will satisfy the query, add ALLOW FILTERING at the end of the query (not recommended if not known).

  • Or make sure the WHERE clause points to one of the keys (see below).

# Create a new table (observe keys)
session.execute("DROP TABLE IF EXISTS my_first_keyspace.car_table;")
session.execute("CREATE TABLE IF NOT EXISTS car_table (company text, model text, PRIMARY KEY(company, model));")
<cassandra.cluster.ResultSet at 0x1075be270>
# Insert some data (combination of company and model must be unique)
session.execute("INSERT INTO car_table (company, model) VALUES ('Tesla', 'Model S');")
session.execute("INSERT INTO car_table (company, model) VALUES ('Tesla', 'Model 3');")
session.execute("INSERT INTO car_table (company, model) VALUES ('Polestar', '3');")
session.execute("INSERT INTO car_table (company, model) VALUES ('Volkswagen', 'ID.4');")
<cassandra.cluster.ResultSet at 0x107e55f70>
# More specific query now works
prepared_statement = session.prepare("SELECT * FROM car_table WHERE company=?;")
teslas = session.execute(prepared_statement, ['Tesla'])
for i in teslas:
    print(i)
Row(company='Tesla', model='Model 3')
Row(company='Tesla', model='Model S')

Partitions#

  • Cassandra databases are usually replicated over different nodes.

  • Data is stored in partitions (subsets) which have local copys.

  • The primary key, e.g., PRIMARY KEY(company, model), is used in partitioning.

    • The first part, e.g., company, is most important.

    • All cars from a company will be located together, aiming for quicker queries.

Unique IDs#

  • In MySQL one could use the attribute AUTO_INCREMENT on integer IDs to automatically make a new unique index when inserting data.

  • This would cause unreasonable overhead in a distributed database.

  • UUIDs are used instead.

    • Universally Unique Identifiers are typically 128-bit random bit sequences with extremely low probability of duplication.

    • Cassandra uses a timeuuid type to combine a timestamp and uuid in one.

# Create a new table (first time only)
session.set_keyspace('my_first_keyspace')
session.execute("DROP TABLE IF EXISTS my_first_keyspace.table_with_uuid;")
session.execute("CREATE TABLE IF NOT EXISTS table_with_uuid (id timeuuid PRIMARY KEY, company text, model text, price float);")
<cassandra.cluster.ResultSet at 0x107e67c20>
session.execute("INSERT INTO table_with_uuid (id, company, model, price) VALUES (now(), 'Tesla', 'Model S', 20000.0);")
session.execute("INSERT INTO table_with_uuid (id, company, model, price) VALUES (now(), 'Tesla', 'Model S', 21000.0);")
session.execute("INSERT INTO table_with_uuid (id, company, model, price) VALUES (now(), 'Oldsmobile', 'Model 6C', 135000.0);")
<cassandra.cluster.ResultSet at 0x107e65820>
from cassandra.util import datetime_from_uuid1

# Query the data
rows = session.execute("SELECT * FROM table_with_uuid;")
for i in rows:
    print(i)
    # Extract the timestamp from Cassandra's timeuuid
    print("Datetime:", datetime_from_uuid1(i.id))
Row(id=UUID('da6b3d90-9ef6-11f0-bcfa-8360e2880d90'), company='Tesla', model='Model S', price=21000.0)
Datetime: 2025-10-01 18:45:51.209000
Row(id=UUID('da6aef70-9ef6-11f0-bcfa-8360e2880d90'), company='Tesla', model='Model S', price=20000.0)
Datetime: 2025-10-01 18:45:51.207000
Row(id=UUID('da6b8bb0-9ef6-11f0-bcfa-8360e2880d90'), company='Oldsmobile', model='Model 6C', price=135000.0)
Datetime: 2025-10-01 18:45:51.211000

JSON in Cassandra#

Read previously saved JSON file forecast.json to memory#

import json
with open('../3_APIs/downloads/forecast.json', 'r') as f:
    forecast = json.load(f)
# Inspect JSON file
forecast.__str__()
"{'cod': '200', 'message': 0, 'cnt': 40, 'list': [{'dt': 1759233600, 'main': {'temp': 285.13, 'feels_like': 284.47, 'temp_min': 285.13, 'temp_max': 287.62, 'pressure': 1029, 'sea_level': 1029, 'grnd_level': 978, 'humidity': 80, 'temp_kf': -2.49}, 'weather': [{'id': 802, 'main': 'Clouds', 'description': 'scattered clouds', 'icon': '03d'}], 'clouds': {'all': 28}, 'wind': {'speed': 0.69, 'deg': 5, 'gust': 0.72}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-09-30 12:00:00'}, {'dt': 1759244400, 'main': {'temp': 285.47, 'feels_like': 284.82, 'temp_min': 285.47, 'temp_max': 286.26, 'pressure': 1029, 'sea_level': 1029, 'grnd_level': 978, 'humidity': 79, 'temp_kf': -0.79}, 'weather': [{'id': 803, 'main': 'Clouds', 'description': 'broken clouds', 'icon': '04d'}], 'clouds': {'all': 69}, 'wind': {'speed': 1.33, 'deg': 293, 'gust': 1.09}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-09-30 15:00:00'}, {'dt': 1759255200, 'main': {'temp': 284.95, 'feels_like': 284.22, 'temp_min': 284.95, 'temp_max': 284.95, 'pressure': 1030, 'sea_level': 1030, 'grnd_level': 979, 'humidity': 78, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04n'}], 'clouds': {'all': 92}, 'wind': {'speed': 1.11, 'deg': 251, 'gust': 1.09}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-09-30 18:00:00'}, {'dt': 1759266000, 'main': {'temp': 282.59, 'feels_like': 282.59, 'temp_min': 282.59, 'temp_max': 282.59, 'pressure': 1030, 'sea_level': 1030, 'grnd_level': 979, 'humidity': 84, 'temp_kf': 0}, 'weather': [{'id': 803, 'main': 'Clouds', 'description': 'broken clouds', 'icon': '04n'}], 'clouds': {'all': 59}, 'wind': {'speed': 0.47, 'deg': 253, 'gust': 0.55}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-09-30 21:00:00'}, {'dt': 1759276800, 'main': {'temp': 281.73, 'feels_like': 281.73, 'temp_min': 281.73, 'temp_max': 281.73, 'pressure': 1030, 'sea_level': 1030, 'grnd_level': 979, 'humidity': 85, 'temp_kf': 0}, 'weather': [{'id': 802, 'main': 'Clouds', 'description': 'scattered clouds', 'icon': '03n'}], 'clouds': {'all': 36}, 'wind': {'speed': 0.16, 'deg': 263, 'gust': 0.28}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-01 00:00:00'}, {'dt': 1759287600, 'main': {'temp': 280.86, 'feels_like': 280.86, 'temp_min': 280.86, 'temp_max': 280.86, 'pressure': 1030, 'sea_level': 1030, 'grnd_level': 978, 'humidity': 86, 'temp_kf': 0}, 'weather': [{'id': 802, 'main': 'Clouds', 'description': 'scattered clouds', 'icon': '03n'}], 'clouds': {'all': 28}, 'wind': {'speed': 0.72, 'deg': 80, 'gust': 0.61}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-01 03:00:00'}, {'dt': 1759298400, 'main': {'temp': 280.91, 'feels_like': 280.91, 'temp_min': 280.91, 'temp_max': 280.91, 'pressure': 1030, 'sea_level': 1030, 'grnd_level': 979, 'humidity': 87, 'temp_kf': 0}, 'weather': [{'id': 801, 'main': 'Clouds', 'description': 'few clouds', 'icon': '02d'}], 'clouds': {'all': 17}, 'wind': {'speed': 0.81, 'deg': 72, 'gust': 0.74}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-01 06:00:00'}, {'dt': 1759309200, 'main': {'temp': 285.11, 'feels_like': 284.22, 'temp_min': 285.11, 'temp_max': 285.11, 'pressure': 1029, 'sea_level': 1029, 'grnd_level': 978, 'humidity': 71, 'temp_kf': 0}, 'weather': [{'id': 801, 'main': 'Clouds', 'description': 'few clouds', 'icon': '02d'}], 'clouds': {'all': 12}, 'wind': {'speed': 1.14, 'deg': 54, 'gust': 1.31}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-01 09:00:00'}, {'dt': 1759320000, 'main': {'temp': 287.53, 'feels_like': 286.56, 'temp_min': 287.53, 'temp_max': 287.53, 'pressure': 1027, 'sea_level': 1027, 'grnd_level': 977, 'humidity': 59, 'temp_kf': 0}, 'weather': [{'id': 800, 'main': 'Clear', 'description': 'clear sky', 'icon': '01d'}], 'clouds': {'all': 9}, 'wind': {'speed': 0.96, 'deg': 70, 'gust': 1.88}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-01 12:00:00'}, {'dt': 1759330800, 'main': {'temp': 286.69, 'feels_like': 285.74, 'temp_min': 286.69, 'temp_max': 286.69, 'pressure': 1026, 'sea_level': 1026, 'grnd_level': 976, 'humidity': 63, 'temp_kf': 0}, 'weather': [{'id': 800, 'main': 'Clear', 'description': 'clear sky', 'icon': '01d'}], 'clouds': {'all': 7}, 'wind': {'speed': 1.85, 'deg': 140, 'gust': 1.89}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-01 15:00:00'}, {'dt': 1759341600, 'main': {'temp': 281.98, 'feels_like': 280.39, 'temp_min': 281.98, 'temp_max': 281.98, 'pressure': 1027, 'sea_level': 1027, 'grnd_level': 975, 'humidity': 71, 'temp_kf': 0}, 'weather': [{'id': 800, 'main': 'Clear', 'description': 'clear sky', 'icon': '01n'}], 'clouds': {'all': 10}, 'wind': {'speed': 2.79, 'deg': 137, 'gust': 2.58}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-01 18:00:00'}, {'dt': 1759352400, 'main': {'temp': 280.08, 'feels_like': 279.17, 'temp_min': 280.08, 'temp_max': 280.08, 'pressure': 1027, 'sea_level': 1027, 'grnd_level': 975, 'humidity': 76, 'temp_kf': 0}, 'weather': [{'id': 800, 'main': 'Clear', 'description': 'clear sky', 'icon': '01n'}], 'clouds': {'all': 8}, 'wind': {'speed': 1.61, 'deg': 133, 'gust': 1.51}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-01 21:00:00'}, {'dt': 1759363200, 'main': {'temp': 279.43, 'feels_like': 278.02, 'temp_min': 279.43, 'temp_max': 279.43, 'pressure': 1025, 'sea_level': 1025, 'grnd_level': 973, 'humidity': 76, 'temp_kf': 0}, 'weather': [{'id': 801, 'main': 'Clouds', 'description': 'few clouds', 'icon': '02n'}], 'clouds': {'all': 11}, 'wind': {'speed': 1.99, 'deg': 110, 'gust': 1.93}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-02 00:00:00'}, {'dt': 1759374000, 'main': {'temp': 278.82, 'feels_like': 277.37, 'temp_min': 278.82, 'temp_max': 278.82, 'pressure': 1024, 'sea_level': 1024, 'grnd_level': 972, 'humidity': 77, 'temp_kf': 0}, 'weather': [{'id': 803, 'main': 'Clouds', 'description': 'broken clouds', 'icon': '04n'}], 'clouds': {'all': 65}, 'wind': {'speed': 1.93, 'deg': 112, 'gust': 1.66}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-02 03:00:00'}, {'dt': 1759384800, 'main': {'temp': 278.76, 'feels_like': 277.2, 'temp_min': 278.76, 'temp_max': 278.76, 'pressure': 1023, 'sea_level': 1023, 'grnd_level': 971, 'humidity': 78, 'temp_kf': 0}, 'weather': [{'id': 803, 'main': 'Clouds', 'description': 'broken clouds', 'icon': '04d'}], 'clouds': {'all': 83}, 'wind': {'speed': 2.03, 'deg': 107, 'gust': 1.6}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-02 06:00:00'}, {'dt': 1759395600, 'main': {'temp': 281.56, 'feels_like': 280.39, 'temp_min': 281.56, 'temp_max': 281.56, 'pressure': 1021, 'sea_level': 1021, 'grnd_level': 970, 'humidity': 68, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 100}, 'wind': {'speed': 2.12, 'deg': 102, 'gust': 2.39}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-02 09:00:00'}, {'dt': 1759406400, 'main': {'temp': 282.84, 'feels_like': 282.84, 'temp_min': 282.84, 'temp_max': 282.84, 'pressure': 1020, 'sea_level': 1020, 'grnd_level': 969, 'humidity': 65, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 100}, 'wind': {'speed': 1.09, 'deg': 59, 'gust': 1.28}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-02 12:00:00'}, {'dt': 1759417200, 'main': {'temp': 282.46, 'feels_like': 282.46, 'temp_min': 282.46, 'temp_max': 282.46, 'pressure': 1019, 'sea_level': 1019, 'grnd_level': 968, 'humidity': 70, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 100}, 'wind': {'speed': 0.71, 'deg': 200, 'gust': 0.24}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-02 15:00:00'}, {'dt': 1759428000, 'main': {'temp': 281.68, 'feels_like': 281.68, 'temp_min': 281.68, 'temp_max': 281.68, 'pressure': 1019, 'sea_level': 1019, 'grnd_level': 967, 'humidity': 81, 'temp_kf': 0}, 'weather': [{'id': 500, 'main': 'Rain', 'description': 'light rain', 'icon': '10n'}], 'clouds': {'all': 100}, 'wind': {'speed': 0.89, 'deg': 65, 'gust': 0.25}, 'visibility': 10000, 'pop': 0.9, 'rain': {'3h': 0.73}, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-02 18:00:00'}, {'dt': 1759438800, 'main': {'temp': 281.86, 'feels_like': 281.86, 'temp_min': 281.86, 'temp_max': 281.86, 'pressure': 1019, 'sea_level': 1019, 'grnd_level': 967, 'humidity': 82, 'temp_kf': 0}, 'weather': [{'id': 500, 'main': 'Rain', 'description': 'light rain', 'icon': '10n'}], 'clouds': {'all': 100}, 'wind': {'speed': 0.7, 'deg': 333, 'gust': 0}, 'visibility': 10000, 'pop': 0.2, 'rain': {'3h': 0.12}, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-02 21:00:00'}, {'dt': 1759449600, 'main': {'temp': 282.05, 'feels_like': 282.05, 'temp_min': 282.05, 'temp_max': 282.05, 'pressure': 1018, 'sea_level': 1018, 'grnd_level': 967, 'humidity': 86, 'temp_kf': 0}, 'weather': [{'id': 500, 'main': 'Rain', 'description': 'light rain', 'icon': '10n'}], 'clouds': {'all': 100}, 'wind': {'speed': 0.34, 'deg': 60, 'gust': 0}, 'visibility': 10000, 'pop': 0.24, 'rain': {'3h': 0.21}, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-03 00:00:00'}, {'dt': 1759460400, 'main': {'temp': 282.07, 'feels_like': 282.07, 'temp_min': 282.07, 'temp_max': 282.07, 'pressure': 1017, 'sea_level': 1017, 'grnd_level': 965, 'humidity': 88, 'temp_kf': 0}, 'weather': [{'id': 500, 'main': 'Rain', 'description': 'light rain', 'icon': '10n'}], 'clouds': {'all': 100}, 'wind': {'speed': 1.2, 'deg': 39, 'gust': 0.4}, 'visibility': 10000, 'pop': 0.25, 'rain': {'3h': 0.23}, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-03 03:00:00'}, {'dt': 1759471200, 'main': {'temp': 283.05, 'feels_like': 281.69, 'temp_min': 283.05, 'temp_max': 283.05, 'pressure': 1015, 'sea_level': 1015, 'grnd_level': 964, 'humidity': 82, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 100}, 'wind': {'speed': 2.75, 'deg': 71, 'gust': 2.42}, 'visibility': 10000, 'pop': 0.01, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-03 06:00:00'}, {'dt': 1759482000, 'main': {'temp': 284.95, 'feels_like': 284.09, 'temp_min': 284.95, 'temp_max': 284.95, 'pressure': 1014, 'sea_level': 1014, 'grnd_level': 964, 'humidity': 73, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 100}, 'wind': {'speed': 2.16, 'deg': 82, 'gust': 2.36}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-03 09:00:00'}, {'dt': 1759492800, 'main': {'temp': 286.44, 'feels_like': 285.57, 'temp_min': 286.44, 'temp_max': 286.44, 'pressure': 1012, 'sea_level': 1012, 'grnd_level': 962, 'humidity': 67, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 100}, 'wind': {'speed': 3.39, 'deg': 93, 'gust': 3.92}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-03 12:00:00'}, {'dt': 1759503600, 'main': {'temp': 284.59, 'feels_like': 283.75, 'temp_min': 284.59, 'temp_max': 284.59, 'pressure': 1011, 'sea_level': 1011, 'grnd_level': 961, 'humidity': 75, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 100}, 'wind': {'speed': 3.39, 'deg': 90, 'gust': 4.42}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-03 15:00:00'}, {'dt': 1759514400, 'main': {'temp': 283.46, 'feels_like': 282.69, 'temp_min': 283.46, 'temp_max': 283.46, 'pressure': 1010, 'sea_level': 1010, 'grnd_level': 960, 'humidity': 82, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04n'}], 'clouds': {'all': 100}, 'wind': {'speed': 3.32, 'deg': 79, 'gust': 4.03}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-03 18:00:00'}, {'dt': 1759525200, 'main': {'temp': 281.91, 'feels_like': 280.07, 'temp_min': 281.91, 'temp_max': 281.91, 'pressure': 1009, 'sea_level': 1009, 'grnd_level': 958, 'humidity': 89, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04n'}], 'clouds': {'all': 100}, 'wind': {'speed': 3.17, 'deg': 83, 'gust': 2.05}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-03 21:00:00'}, {'dt': 1759536000, 'main': {'temp': 281.45, 'feels_like': 279.65, 'temp_min': 281.45, 'temp_max': 281.45, 'pressure': 1008, 'sea_level': 1008, 'grnd_level': 957, 'humidity': 79, 'temp_kf': 0}, 'weather': [{'id': 803, 'main': 'Clouds', 'description': 'broken clouds', 'icon': '04n'}], 'clouds': {'all': 70}, 'wind': {'speed': 2.95, 'deg': 81, 'gust': 1.5}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-04 00:00:00'}, {'dt': 1759546800, 'main': {'temp': 280.74, 'feels_like': 278.43, 'temp_min': 280.74, 'temp_max': 280.74, 'pressure': 1006, 'sea_level': 1006, 'grnd_level': 956, 'humidity': 77, 'temp_kf': 0}, 'weather': [{'id': 802, 'main': 'Clouds', 'description': 'scattered clouds', 'icon': '03n'}], 'clouds': {'all': 32}, 'wind': {'speed': 3.56, 'deg': 85, 'gust': 2.5}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-04 03:00:00'}, {'dt': 1759557600, 'main': {'temp': 279.28, 'feels_like': 276.67, 'temp_min': 279.28, 'temp_max': 279.28, 'pressure': 1006, 'sea_level': 1006, 'grnd_level': 955, 'humidity': 82, 'temp_kf': 0}, 'weather': [{'id': 801, 'main': 'Clouds', 'description': 'few clouds', 'icon': '02d'}], 'clouds': {'all': 19}, 'wind': {'speed': 3.53, 'deg': 91, 'gust': 3.17}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-04 06:00:00'}, {'dt': 1759568400, 'main': {'temp': 282.91, 'feels_like': 280.03, 'temp_min': 282.91, 'temp_max': 282.91, 'pressure': 1005, 'sea_level': 1005, 'grnd_level': 954, 'humidity': 60, 'temp_kf': 0}, 'weather': [{'id': 800, 'main': 'Clear', 'description': 'clear sky', 'icon': '01d'}], 'clouds': {'all': 6}, 'wind': {'speed': 6.18, 'deg': 81, 'gust': 9.51}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-04 09:00:00'}, {'dt': 1759579200, 'main': {'temp': 283.51, 'feels_like': 282.17, 'temp_min': 283.51, 'temp_max': 283.51, 'pressure': 1003, 'sea_level': 1003, 'grnd_level': 952, 'humidity': 60, 'temp_kf': 0}, 'weather': [{'id': 802, 'main': 'Clouds', 'description': 'scattered clouds', 'icon': '03d'}], 'clouds': {'all': 30}, 'wind': {'speed': 6.63, 'deg': 86, 'gust': 12.84}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-04 12:00:00'}, {'dt': 1759590000, 'main': {'temp': 281.36, 'feels_like': 278.41, 'temp_min': 281.36, 'temp_max': 281.36, 'pressure': 1002, 'sea_level': 1002, 'grnd_level': 951, 'humidity': 81, 'temp_kf': 0}, 'weather': [{'id': 803, 'main': 'Clouds', 'description': 'broken clouds', 'icon': '04d'}], 'clouds': {'all': 71}, 'wind': {'speed': 5.22, 'deg': 83, 'gust': 11.14}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-04 15:00:00'}, {'dt': 1759600800, 'main': {'temp': 281.33, 'feels_like': 278.35, 'temp_min': 281.33, 'temp_max': 281.33, 'pressure': 1002, 'sea_level': 1002, 'grnd_level': 951, 'humidity': 76, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04n'}], 'clouds': {'all': 85}, 'wind': {'speed': 5.28, 'deg': 83, 'gust': 10.04}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-04 18:00:00'}, {'dt': 1759611600, 'main': {'temp': 280.7, 'feels_like': 277.77, 'temp_min': 280.7, 'temp_max': 280.7, 'pressure': 1001, 'sea_level': 1001, 'grnd_level': 951, 'humidity': 74, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04n'}], 'clouds': {'all': 98}, 'wind': {'speed': 4.78, 'deg': 76, 'gust': 8.82}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-04 21:00:00'}, {'dt': 1759622400, 'main': {'temp': 279.18, 'feels_like': 276.42, 'temp_min': 279.18, 'temp_max': 279.18, 'pressure': 1001, 'sea_level': 1001, 'grnd_level': 950, 'humidity': 82, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04n'}], 'clouds': {'all': 96}, 'wind': {'speed': 3.74, 'deg': 63, 'gust': 6.16}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-05 00:00:00'}, {'dt': 1759633200, 'main': {'temp': 279.53, 'feels_like': 276.95, 'temp_min': 279.53, 'temp_max': 279.53, 'pressure': 1000, 'sea_level': 1000, 'grnd_level': 949, 'humidity': 78, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04n'}], 'clouds': {'all': 99}, 'wind': {'speed': 3.56, 'deg': 63, 'gust': 5.68}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-05 03:00:00'}, {'dt': 1759644000, 'main': {'temp': 279.81, 'feels_like': 277.39, 'temp_min': 279.81, 'temp_max': 279.81, 'pressure': 1000, 'sea_level': 1000, 'grnd_level': 949, 'humidity': 79, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 98}, 'wind': {'speed': 3.4, 'deg': 63, 'gust': 5.66}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-05 06:00:00'}, {'dt': 1759654800, 'main': {'temp': 280.55, 'feels_like': 277.81, 'temp_min': 280.55, 'temp_max': 280.55, 'pressure': 1000, 'sea_level': 1000, 'grnd_level': 949, 'humidity': 77, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 100}, 'wind': {'speed': 4.29, 'deg': 71, 'gust': 10.36}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-05 09:00:00'}], 'city': {'id': 3145614, 'name': 'Mo i Rana', 'coord': {'lat': 66.3128, 'lon': 14.1428}, 'country': 'NO', 'population': 17853, 'timezone': 7200, 'sunrise': 1759209065, 'sunset': 1759250136}}"

Raw JSON#

  • A simple, but not very efficient way of storing JSON data is to treat it as a text and save it directly to the database.

  • More efficient, with regard to transfer, is to compress the JSON data to a blob first.

    • Compression is automatic.

# Create a new table which treats the whole JSON as a blob, using the city id and the first dt as keys
session.set_keyspace('my_first_keyspace')
session.execute("DROP TABLE IF EXISTS my_first_keyspace.forecast_table;")
session.execute("CREATE TABLE IF NOT EXISTS forecast_table (city_id int, dt int, forecast blob, PRIMARY KEY(city_id, dt));")
<cassandra.cluster.ResultSet at 0x1182ca0f0>

Insert the forecast data into the table as text blob#

session.execute("INSERT INTO forecast_table (city_id, dt, forecast) VALUES (%s, %s, textAsBlob(%s));", (forecast['city']['id'], forecast['list'][0]['dt'], forecast.__str__()))
<cassandra.cluster.ResultSet at 0x10735ba40>
# Query the data
forecast_rows = session.execute("SELECT * FROM forecast_table;")
print(forecast_rows.one()) # <- only one row
Row(city_id=3145614, dt=1759233600, forecast=b"{'cod': '200', 'message': 0, 'cnt': 40, 'list': [{'dt': 1759233600, 'main': {'temp': 285.13, 'feels_like': 284.47, 'temp_min': 285.13, 'temp_max': 287.62, 'pressure': 1029, 'sea_level': 1029, 'grnd_level': 978, 'humidity': 80, 'temp_kf': -2.49}, 'weather': [{'id': 802, 'main': 'Clouds', 'description': 'scattered clouds', 'icon': '03d'}], 'clouds': {'all': 28}, 'wind': {'speed': 0.69, 'deg': 5, 'gust': 0.72}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-09-30 12:00:00'}, {'dt': 1759244400, 'main': {'temp': 285.47, 'feels_like': 284.82, 'temp_min': 285.47, 'temp_max': 286.26, 'pressure': 1029, 'sea_level': 1029, 'grnd_level': 978, 'humidity': 79, 'temp_kf': -0.79}, 'weather': [{'id': 803, 'main': 'Clouds', 'description': 'broken clouds', 'icon': '04d'}], 'clouds': {'all': 69}, 'wind': {'speed': 1.33, 'deg': 293, 'gust': 1.09}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-09-30 15:00:00'}, {'dt': 1759255200, 'main': {'temp': 284.95, 'feels_like': 284.22, 'temp_min': 284.95, 'temp_max': 284.95, 'pressure': 1030, 'sea_level': 1030, 'grnd_level': 979, 'humidity': 78, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04n'}], 'clouds': {'all': 92}, 'wind': {'speed': 1.11, 'deg': 251, 'gust': 1.09}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-09-30 18:00:00'}, {'dt': 1759266000, 'main': {'temp': 282.59, 'feels_like': 282.59, 'temp_min': 282.59, 'temp_max': 282.59, 'pressure': 1030, 'sea_level': 1030, 'grnd_level': 979, 'humidity': 84, 'temp_kf': 0}, 'weather': [{'id': 803, 'main': 'Clouds', 'description': 'broken clouds', 'icon': '04n'}], 'clouds': {'all': 59}, 'wind': {'speed': 0.47, 'deg': 253, 'gust': 0.55}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-09-30 21:00:00'}, {'dt': 1759276800, 'main': {'temp': 281.73, 'feels_like': 281.73, 'temp_min': 281.73, 'temp_max': 281.73, 'pressure': 1030, 'sea_level': 1030, 'grnd_level': 979, 'humidity': 85, 'temp_kf': 0}, 'weather': [{'id': 802, 'main': 'Clouds', 'description': 'scattered clouds', 'icon': '03n'}], 'clouds': {'all': 36}, 'wind': {'speed': 0.16, 'deg': 263, 'gust': 0.28}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-01 00:00:00'}, {'dt': 1759287600, 'main': {'temp': 280.86, 'feels_like': 280.86, 'temp_min': 280.86, 'temp_max': 280.86, 'pressure': 1030, 'sea_level': 1030, 'grnd_level': 978, 'humidity': 86, 'temp_kf': 0}, 'weather': [{'id': 802, 'main': 'Clouds', 'description': 'scattered clouds', 'icon': '03n'}], 'clouds': {'all': 28}, 'wind': {'speed': 0.72, 'deg': 80, 'gust': 0.61}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-01 03:00:00'}, {'dt': 1759298400, 'main': {'temp': 280.91, 'feels_like': 280.91, 'temp_min': 280.91, 'temp_max': 280.91, 'pressure': 1030, 'sea_level': 1030, 'grnd_level': 979, 'humidity': 87, 'temp_kf': 0}, 'weather': [{'id': 801, 'main': 'Clouds', 'description': 'few clouds', 'icon': '02d'}], 'clouds': {'all': 17}, 'wind': {'speed': 0.81, 'deg': 72, 'gust': 0.74}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-01 06:00:00'}, {'dt': 1759309200, 'main': {'temp': 285.11, 'feels_like': 284.22, 'temp_min': 285.11, 'temp_max': 285.11, 'pressure': 1029, 'sea_level': 1029, 'grnd_level': 978, 'humidity': 71, 'temp_kf': 0}, 'weather': [{'id': 801, 'main': 'Clouds', 'description': 'few clouds', 'icon': '02d'}], 'clouds': {'all': 12}, 'wind': {'speed': 1.14, 'deg': 54, 'gust': 1.31}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-01 09:00:00'}, {'dt': 1759320000, 'main': {'temp': 287.53, 'feels_like': 286.56, 'temp_min': 287.53, 'temp_max': 287.53, 'pressure': 1027, 'sea_level': 1027, 'grnd_level': 977, 'humidity': 59, 'temp_kf': 0}, 'weather': [{'id': 800, 'main': 'Clear', 'description': 'clear sky', 'icon': '01d'}], 'clouds': {'all': 9}, 'wind': {'speed': 0.96, 'deg': 70, 'gust': 1.88}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-01 12:00:00'}, {'dt': 1759330800, 'main': {'temp': 286.69, 'feels_like': 285.74, 'temp_min': 286.69, 'temp_max': 286.69, 'pressure': 1026, 'sea_level': 1026, 'grnd_level': 976, 'humidity': 63, 'temp_kf': 0}, 'weather': [{'id': 800, 'main': 'Clear', 'description': 'clear sky', 'icon': '01d'}], 'clouds': {'all': 7}, 'wind': {'speed': 1.85, 'deg': 140, 'gust': 1.89}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-01 15:00:00'}, {'dt': 1759341600, 'main': {'temp': 281.98, 'feels_like': 280.39, 'temp_min': 281.98, 'temp_max': 281.98, 'pressure': 1027, 'sea_level': 1027, 'grnd_level': 975, 'humidity': 71, 'temp_kf': 0}, 'weather': [{'id': 800, 'main': 'Clear', 'description': 'clear sky', 'icon': '01n'}], 'clouds': {'all': 10}, 'wind': {'speed': 2.79, 'deg': 137, 'gust': 2.58}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-01 18:00:00'}, {'dt': 1759352400, 'main': {'temp': 280.08, 'feels_like': 279.17, 'temp_min': 280.08, 'temp_max': 280.08, 'pressure': 1027, 'sea_level': 1027, 'grnd_level': 975, 'humidity': 76, 'temp_kf': 0}, 'weather': [{'id': 800, 'main': 'Clear', 'description': 'clear sky', 'icon': '01n'}], 'clouds': {'all': 8}, 'wind': {'speed': 1.61, 'deg': 133, 'gust': 1.51}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-01 21:00:00'}, {'dt': 1759363200, 'main': {'temp': 279.43, 'feels_like': 278.02, 'temp_min': 279.43, 'temp_max': 279.43, 'pressure': 1025, 'sea_level': 1025, 'grnd_level': 973, 'humidity': 76, 'temp_kf': 0}, 'weather': [{'id': 801, 'main': 'Clouds', 'description': 'few clouds', 'icon': '02n'}], 'clouds': {'all': 11}, 'wind': {'speed': 1.99, 'deg': 110, 'gust': 1.93}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-02 00:00:00'}, {'dt': 1759374000, 'main': {'temp': 278.82, 'feels_like': 277.37, 'temp_min': 278.82, 'temp_max': 278.82, 'pressure': 1024, 'sea_level': 1024, 'grnd_level': 972, 'humidity': 77, 'temp_kf': 0}, 'weather': [{'id': 803, 'main': 'Clouds', 'description': 'broken clouds', 'icon': '04n'}], 'clouds': {'all': 65}, 'wind': {'speed': 1.93, 'deg': 112, 'gust': 1.66}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-02 03:00:00'}, {'dt': 1759384800, 'main': {'temp': 278.76, 'feels_like': 277.2, 'temp_min': 278.76, 'temp_max': 278.76, 'pressure': 1023, 'sea_level': 1023, 'grnd_level': 971, 'humidity': 78, 'temp_kf': 0}, 'weather': [{'id': 803, 'main': 'Clouds', 'description': 'broken clouds', 'icon': '04d'}], 'clouds': {'all': 83}, 'wind': {'speed': 2.03, 'deg': 107, 'gust': 1.6}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-02 06:00:00'}, {'dt': 1759395600, 'main': {'temp': 281.56, 'feels_like': 280.39, 'temp_min': 281.56, 'temp_max': 281.56, 'pressure': 1021, 'sea_level': 1021, 'grnd_level': 970, 'humidity': 68, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 100}, 'wind': {'speed': 2.12, 'deg': 102, 'gust': 2.39}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-02 09:00:00'}, {'dt': 1759406400, 'main': {'temp': 282.84, 'feels_like': 282.84, 'temp_min': 282.84, 'temp_max': 282.84, 'pressure': 1020, 'sea_level': 1020, 'grnd_level': 969, 'humidity': 65, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 100}, 'wind': {'speed': 1.09, 'deg': 59, 'gust': 1.28}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-02 12:00:00'}, {'dt': 1759417200, 'main': {'temp': 282.46, 'feels_like': 282.46, 'temp_min': 282.46, 'temp_max': 282.46, 'pressure': 1019, 'sea_level': 1019, 'grnd_level': 968, 'humidity': 70, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 100}, 'wind': {'speed': 0.71, 'deg': 200, 'gust': 0.24}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-02 15:00:00'}, {'dt': 1759428000, 'main': {'temp': 281.68, 'feels_like': 281.68, 'temp_min': 281.68, 'temp_max': 281.68, 'pressure': 1019, 'sea_level': 1019, 'grnd_level': 967, 'humidity': 81, 'temp_kf': 0}, 'weather': [{'id': 500, 'main': 'Rain', 'description': 'light rain', 'icon': '10n'}], 'clouds': {'all': 100}, 'wind': {'speed': 0.89, 'deg': 65, 'gust': 0.25}, 'visibility': 10000, 'pop': 0.9, 'rain': {'3h': 0.73}, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-02 18:00:00'}, {'dt': 1759438800, 'main': {'temp': 281.86, 'feels_like': 281.86, 'temp_min': 281.86, 'temp_max': 281.86, 'pressure': 1019, 'sea_level': 1019, 'grnd_level': 967, 'humidity': 82, 'temp_kf': 0}, 'weather': [{'id': 500, 'main': 'Rain', 'description': 'light rain', 'icon': '10n'}], 'clouds': {'all': 100}, 'wind': {'speed': 0.7, 'deg': 333, 'gust': 0}, 'visibility': 10000, 'pop': 0.2, 'rain': {'3h': 0.12}, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-02 21:00:00'}, {'dt': 1759449600, 'main': {'temp': 282.05, 'feels_like': 282.05, 'temp_min': 282.05, 'temp_max': 282.05, 'pressure': 1018, 'sea_level': 1018, 'grnd_level': 967, 'humidity': 86, 'temp_kf': 0}, 'weather': [{'id': 500, 'main': 'Rain', 'description': 'light rain', 'icon': '10n'}], 'clouds': {'all': 100}, 'wind': {'speed': 0.34, 'deg': 60, 'gust': 0}, 'visibility': 10000, 'pop': 0.24, 'rain': {'3h': 0.21}, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-03 00:00:00'}, {'dt': 1759460400, 'main': {'temp': 282.07, 'feels_like': 282.07, 'temp_min': 282.07, 'temp_max': 282.07, 'pressure': 1017, 'sea_level': 1017, 'grnd_level': 965, 'humidity': 88, 'temp_kf': 0}, 'weather': [{'id': 500, 'main': 'Rain', 'description': 'light rain', 'icon': '10n'}], 'clouds': {'all': 100}, 'wind': {'speed': 1.2, 'deg': 39, 'gust': 0.4}, 'visibility': 10000, 'pop': 0.25, 'rain': {'3h': 0.23}, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-03 03:00:00'}, {'dt': 1759471200, 'main': {'temp': 283.05, 'feels_like': 281.69, 'temp_min': 283.05, 'temp_max': 283.05, 'pressure': 1015, 'sea_level': 1015, 'grnd_level': 964, 'humidity': 82, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 100}, 'wind': {'speed': 2.75, 'deg': 71, 'gust': 2.42}, 'visibility': 10000, 'pop': 0.01, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-03 06:00:00'}, {'dt': 1759482000, 'main': {'temp': 284.95, 'feels_like': 284.09, 'temp_min': 284.95, 'temp_max': 284.95, 'pressure': 1014, 'sea_level': 1014, 'grnd_level': 964, 'humidity': 73, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 100}, 'wind': {'speed': 2.16, 'deg': 82, 'gust': 2.36}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-03 09:00:00'}, {'dt': 1759492800, 'main': {'temp': 286.44, 'feels_like': 285.57, 'temp_min': 286.44, 'temp_max': 286.44, 'pressure': 1012, 'sea_level': 1012, 'grnd_level': 962, 'humidity': 67, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 100}, 'wind': {'speed': 3.39, 'deg': 93, 'gust': 3.92}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-03 12:00:00'}, {'dt': 1759503600, 'main': {'temp': 284.59, 'feels_like': 283.75, 'temp_min': 284.59, 'temp_max': 284.59, 'pressure': 1011, 'sea_level': 1011, 'grnd_level': 961, 'humidity': 75, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 100}, 'wind': {'speed': 3.39, 'deg': 90, 'gust': 4.42}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-03 15:00:00'}, {'dt': 1759514400, 'main': {'temp': 283.46, 'feels_like': 282.69, 'temp_min': 283.46, 'temp_max': 283.46, 'pressure': 1010, 'sea_level': 1010, 'grnd_level': 960, 'humidity': 82, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04n'}], 'clouds': {'all': 100}, 'wind': {'speed': 3.32, 'deg': 79, 'gust': 4.03}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-03 18:00:00'}, {'dt': 1759525200, 'main': {'temp': 281.91, 'feels_like': 280.07, 'temp_min': 281.91, 'temp_max': 281.91, 'pressure': 1009, 'sea_level': 1009, 'grnd_level': 958, 'humidity': 89, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04n'}], 'clouds': {'all': 100}, 'wind': {'speed': 3.17, 'deg': 83, 'gust': 2.05}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-03 21:00:00'}, {'dt': 1759536000, 'main': {'temp': 281.45, 'feels_like': 279.65, 'temp_min': 281.45, 'temp_max': 281.45, 'pressure': 1008, 'sea_level': 1008, 'grnd_level': 957, 'humidity': 79, 'temp_kf': 0}, 'weather': [{'id': 803, 'main': 'Clouds', 'description': 'broken clouds', 'icon': '04n'}], 'clouds': {'all': 70}, 'wind': {'speed': 2.95, 'deg': 81, 'gust': 1.5}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-04 00:00:00'}, {'dt': 1759546800, 'main': {'temp': 280.74, 'feels_like': 278.43, 'temp_min': 280.74, 'temp_max': 280.74, 'pressure': 1006, 'sea_level': 1006, 'grnd_level': 956, 'humidity': 77, 'temp_kf': 0}, 'weather': [{'id': 802, 'main': 'Clouds', 'description': 'scattered clouds', 'icon': '03n'}], 'clouds': {'all': 32}, 'wind': {'speed': 3.56, 'deg': 85, 'gust': 2.5}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-04 03:00:00'}, {'dt': 1759557600, 'main': {'temp': 279.28, 'feels_like': 276.67, 'temp_min': 279.28, 'temp_max': 279.28, 'pressure': 1006, 'sea_level': 1006, 'grnd_level': 955, 'humidity': 82, 'temp_kf': 0}, 'weather': [{'id': 801, 'main': 'Clouds', 'description': 'few clouds', 'icon': '02d'}], 'clouds': {'all': 19}, 'wind': {'speed': 3.53, 'deg': 91, 'gust': 3.17}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-04 06:00:00'}, {'dt': 1759568400, 'main': {'temp': 282.91, 'feels_like': 280.03, 'temp_min': 282.91, 'temp_max': 282.91, 'pressure': 1005, 'sea_level': 1005, 'grnd_level': 954, 'humidity': 60, 'temp_kf': 0}, 'weather': [{'id': 800, 'main': 'Clear', 'description': 'clear sky', 'icon': '01d'}], 'clouds': {'all': 6}, 'wind': {'speed': 6.18, 'deg': 81, 'gust': 9.51}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-04 09:00:00'}, {'dt': 1759579200, 'main': {'temp': 283.51, 'feels_like': 282.17, 'temp_min': 283.51, 'temp_max': 283.51, 'pressure': 1003, 'sea_level': 1003, 'grnd_level': 952, 'humidity': 60, 'temp_kf': 0}, 'weather': [{'id': 802, 'main': 'Clouds', 'description': 'scattered clouds', 'icon': '03d'}], 'clouds': {'all': 30}, 'wind': {'speed': 6.63, 'deg': 86, 'gust': 12.84}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-04 12:00:00'}, {'dt': 1759590000, 'main': {'temp': 281.36, 'feels_like': 278.41, 'temp_min': 281.36, 'temp_max': 281.36, 'pressure': 1002, 'sea_level': 1002, 'grnd_level': 951, 'humidity': 81, 'temp_kf': 0}, 'weather': [{'id': 803, 'main': 'Clouds', 'description': 'broken clouds', 'icon': '04d'}], 'clouds': {'all': 71}, 'wind': {'speed': 5.22, 'deg': 83, 'gust': 11.14}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-04 15:00:00'}, {'dt': 1759600800, 'main': {'temp': 281.33, 'feels_like': 278.35, 'temp_min': 281.33, 'temp_max': 281.33, 'pressure': 1002, 'sea_level': 1002, 'grnd_level': 951, 'humidity': 76, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04n'}], 'clouds': {'all': 85}, 'wind': {'speed': 5.28, 'deg': 83, 'gust': 10.04}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-04 18:00:00'}, {'dt': 1759611600, 'main': {'temp': 280.7, 'feels_like': 277.77, 'temp_min': 280.7, 'temp_max': 280.7, 'pressure': 1001, 'sea_level': 1001, 'grnd_level': 951, 'humidity': 74, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04n'}], 'clouds': {'all': 98}, 'wind': {'speed': 4.78, 'deg': 76, 'gust': 8.82}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-04 21:00:00'}, {'dt': 1759622400, 'main': {'temp': 279.18, 'feels_like': 276.42, 'temp_min': 279.18, 'temp_max': 279.18, 'pressure': 1001, 'sea_level': 1001, 'grnd_level': 950, 'humidity': 82, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04n'}], 'clouds': {'all': 96}, 'wind': {'speed': 3.74, 'deg': 63, 'gust': 6.16}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-05 00:00:00'}, {'dt': 1759633200, 'main': {'temp': 279.53, 'feels_like': 276.95, 'temp_min': 279.53, 'temp_max': 279.53, 'pressure': 1000, 'sea_level': 1000, 'grnd_level': 949, 'humidity': 78, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04n'}], 'clouds': {'all': 99}, 'wind': {'speed': 3.56, 'deg': 63, 'gust': 5.68}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'n'}, 'dt_txt': '2025-10-05 03:00:00'}, {'dt': 1759644000, 'main': {'temp': 279.81, 'feels_like': 277.39, 'temp_min': 279.81, 'temp_max': 279.81, 'pressure': 1000, 'sea_level': 1000, 'grnd_level': 949, 'humidity': 79, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 98}, 'wind': {'speed': 3.4, 'deg': 63, 'gust': 5.66}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-05 06:00:00'}, {'dt': 1759654800, 'main': {'temp': 280.55, 'feels_like': 277.81, 'temp_min': 280.55, 'temp_max': 280.55, 'pressure': 1000, 'sea_level': 1000, 'grnd_level': 949, 'humidity': 77, 'temp_kf': 0}, 'weather': [{'id': 804, 'main': 'Clouds', 'description': 'overcast clouds', 'icon': '04d'}], 'clouds': {'all': 100}, 'wind': {'speed': 4.29, 'deg': 71, 'gust': 10.36}, 'visibility': 10000, 'pop': 0, 'sys': {'pod': 'd'}, 'dt_txt': '2025-10-05 09:00:00'}], 'city': {'id': 3145614, 'name': 'Mo i Rana', 'coord': {'lat': 66.3128, 'lon': 14.1428}, 'country': 'NO', 'population': 17853, 'timezone': 7200, 'sunrise': 1759209065, 'sunset': 1759250136}}")