<jupyter_start><jupyter_text>Changefeed experiments - 1with [rethinkdb](https://rethinkdb.com/docs/changefeeds/python/)<jupyter_code># Load the driver
import rethinkdb as r
import sys
from beeprint import pp

# variables
host = 'localhost'
db = 'mydb'
table = 'mytable'

# connect and create
r.connect(host=host).repl()
if db not in r.db_list().run():
    r.db_create(db).run()
if table not in r.db(db).table_list().run():
    r.db(db).table_create(table).run()<jupyter_output><empty_output><jupyter_text>Access the [internal dashboard](http://192.168.3.11:4327/dataexplorer) to see what is happening,e.g. with the javascript command```javascriptr.db('mydb').table('mytable')```<jupyter_code># register this notebook to modifications
query = r.db(db).table(table)

try:
    for change in query.changes().run():
        print("Subscription update!")
        pp(change)
except Exception as e:
    print("Table removed or connection aborted")<jupyter_output>Subscription update!
{
  'new_val': {
    'id': '2a8a8adc-887d-4e49-be3c-8be9e60fe317',
    'key1': 'value1',
    'key2': 'value2',
  },
  'old_val': None,
}
Subscription update!
{
  'new_val': {
    'id': '82f19bbc-84c9-45e4-b12c-d94fff27dde2',
    'key1': 'value1',
    'key2': 'value2',
  },
  'old_val': None,
}
Subscription update!
{
  'new_val': {
    'id': '40587705-d7df-45aa-a3cc-cf074aca2226',
    'key1': 'value3',
    'key2': 'value4',
  },
  'old_val': None,
}
Subscription update!
{
  'new_val': {
    'id': 'c3e934e4-5586-4ee8-b95f-de1a670848ff',
    'key1': 'UPDATED!',
    'key2': 'value2',
  },
  'old_val': {
    'id': 'c3e934e4-5586-4ee8-b95f-de1a670848ff',
    'key1': 'value1',
    'key2': 'value2',
  },
}
Subscription update!
{
  'new_val': {
    'id': '2a8a8adc-887d-4e49-be3c-8be9e60fe317',
    'key1': 'UPDATED!',
    'key2': 'value2',
  },
  'old_val': {
    'id': '2a8a8adc-887d-4e49-be3c-8be9e60fe317',
    'key1': 'value1',
    'key2': 'value2',
  },
}
Subscription upd[...]
{'fraction_non_alphanumeric': 0.188265306122449, 'fraction_numerical': 0.08520408163265306, 'mean_word_length': 4.015345268542199, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '434586', 'license': 'MIT', 'n_tokens_mistral': 907, 'n_tokens_neox': 850, 'n_words': 142, 'path': 'rethinkdb_jupyter/notebooks/changefeed/FEED create and register.ipynb', 'repo_name': 'pdonorio/pocs', 'size': '1962'}