<jupyter_start><jupyter_text>https://jeffknupp.com/blog/2014/09/01/what-is-a-nosql-database-learn-by-writing-one-in-python/Schema: a description of the names of the columns and the type of data they contain. It also contains information like which columns can be blank, which must be unique, and all other constraints on column values. A table may only have one schema at any given time and all rows in the table must conform to the schema. This is an important restriction. Imagine you have a database table with millions of rows of customer information. Your sales team would like to begin capturing an additional piece of data (say, the user's age) to increase the precision of their email marketing algorithm. This requires you to alter the table by adding a column. You'll also need to decide if each row in the table needs a value for this column. Often times, it makes sense to make a column required, but doing so would require information we simply don't have access to (like the age of every user already in the database). Therefore, trade offs are often made in this regard.In addition, making schema changes to very large database tables is rarely a simple matter. Having a rollback plan in case something goes wrong is important, but it's not always possible to undo a schema change once it's been made. Schema maintenance is probably one of the most difficult parts of the job of a DBA. NoSQLNoSQL db do not have a schema, they are simply key/value stores.To understand how they work, let's write one ourselves! We'll start with a very simple design:* A Python dict as the primary data store* Only support strings as keys* Support for storing integers, strings, and lists* A simple TCP/IP server that uses ASCII strings for messaging* Slightly advanced commands like INCREMENT, DELETE, APPEND, and STATSThe benefit of building the data store with an ASCII-based TCP/IP interface is that we can use the simple telnet program to interact with our server; no special client is needed (though writing one would be a good exercise and can be done in about 15 lines). run nosql.py and connect  https://github.com/jeffknupp/nosql<jupyter_code>import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('localhost', 50505))<jupyter_output><empty_output><jupyter_text>New connection from [('127.0.0.1', 53111)]<jupyter_code>command = 'PUT;foo;1;'.encode()
s.sendall(command)  # TypeError: a bytes-like object is required, not 'str', crashes server
response = s.recv(4096)
print(response)
s.sendall(b'GET;foo;;')
response = s.recv(4096)
#s.close()
print(response)
s.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06547392462885421, 'fraction_numerical': 0.013323182337266844, 'mean_word_length': 4.959183673469388, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '403286', 'license': 'MIT', 'n_tokens_mistral': 722, 'n_tokens_neox': 678, 'n_words': 375, 'path': 'NoSQL/NoSQL tutorial 17-10-2017.ipynb', 'repo_name': 'afcarl/Useful-python', 'size': '2627'}