10 Application development with ScyllaDB

 

This chapter covers

  • Creating a Flask application to connect to your cluster using the Scylla driver
  • Building an API that executes queries against ScyllaDB
  • Tuning the driver’s consistency, load-balancing, and query retry behavior
  • Authenticating and authorizing connections to the cluster

On top of every database is at least one application that interacts with it. Maybe it’s an API, or perhaps a data analytics system. An API needs to provide an interface for users to create, store, and remove data via HTTP requests. A data analytics system may query the entire database—you’ll see how to approach this problem in chapter 12—to transfer data into another system for further aggregation. By building an application on top of the cluster, you allow a database to provide its benefits beyond people who understand its schema and how to write a database query.

In this chapter, you’ll learn how to use ScyllaDB in an application. By using the database driver, a software library for connecting to a database, you’ll build a small Python application that queries ScyllaDB by exposing an API. Along the way, you’ll learn how to best configure the driver for production systems and how to tackle some real-world application and database concerns: authentication and authorization. However, before you can connect to your database, it’s time to set up the application.

10.1 Your application

10.1.1 Python

10.1.2 Virtual environments

10.1.3 Flask

10.2 Querying Scylla

10.2.1 A new Scylla cluster

10.2.2 Connecting to the cluster

10.2.3 Your first application query

10.3 Reading data

10.3.1 Prepared statements

10.3.2 Reading articles

10.4 Writing data

10.4.1 The necessary data

10.4.2 Laying the write groundwork

10.4.3 Batch-writing articles

10.4.4 Working with user-defined types

10.5 Configuring the driver

10.5.1 Consistency

10.5.2 Load balancing

10.5.3 Retrying queries

10.6 Authentication and authorization