{"id":27370223,"url":"https://github.com/datastaxdevs/workshop-cassandra-application-development","last_synced_at":"2026-03-05T16:14:07.880Z","repository":{"id":43139190,"uuid":"509521704","full_name":"datastaxdevs/workshop-cassandra-application-development","owner":"datastaxdevs","description":"Learn about drivers, connectivity and requests by running a simple API with Apache Cassandra/Astra DB as its data backend.","archived":false,"fork":false,"pushed_at":"2023-01-24T22:54:47.000Z","size":10891,"stargazers_count":11,"open_issues_count":0,"forks_count":10,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-13T08:57:12.738Z","etag":null,"topics":["cassandra","drivers","nosql","workshop"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datastaxdevs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-01T16:28:14.000Z","updated_at":"2023-12-12T16:42:33.000Z","dependencies_parsed_at":"2023-01-30T02:00:34.910Z","dependency_job_id":null,"html_url":"https://github.com/datastaxdevs/workshop-cassandra-application-development","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/datastaxdevs/workshop-cassandra-application-development","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datastaxdevs%2Fworkshop-cassandra-application-development","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datastaxdevs%2Fworkshop-cassandra-application-development/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datastaxdevs%2Fworkshop-cassandra-application-development/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datastaxdevs%2Fworkshop-cassandra-application-development/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datastaxdevs","download_url":"https://codeload.github.com/datastaxdevs/workshop-cassandra-application-development/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datastaxdevs%2Fworkshop-cassandra-application-development/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261406777,"owners_count":23153835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cassandra","drivers","nosql","workshop"],"created_at":"2025-04-13T08:48:22.705Z","updated_at":"2026-03-05T16:14:07.839Z","avatar_url":"https://github.com/datastaxdevs.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Workshop - Application Development with Cassandra\n\nLearn about drivers, connectivity and requests by running a simple API with\nApache Cassandra/Astra DB as its data backend. The steps are available in _several languages_.\n\nClick here for the workshop [slide deck](slides/slides.pdf).\n\n### Pre-requisites\n\nThis workshop, the third in a series, builds on the same example used in the two previous episodes (an IoT application to access temperature measurements collected from a network of sensors).\n\nBesides some knowledge of the [example domain](https://www.datastax.com/learn/data-modeling-by-example/sensor-data-model) used in this workshop, it is desirable to have familiarity with the concepts explored in the two previous installments of the series:\n\n- [Cassandra Fundamentals](https://github.com/datastaxdevs/workshop-cassandra-fundamentals)\n- [Data Modeling with Cassandra](https://github.com/datastaxdevs/workshop-cassandra-data-modeling)\n\n#### Database pre-requisites\n\nIt is assumed in the following that you already have created your [Astra DB instance](https://github.com/datastaxdevs/workshop-cassandra-fundamentals#4-create-your-astra-db-instance) as instructed in the first episode, and that you have a valid \"DB Administrator\" Token.\n**Note**: the Token that is created with the database does not have all permissions we need, so you _need_ to manually [create a Token](https://awesome-astra.github.io/docs/pages/astra/create-token/) with the higher \"DB Administrator\" permission and use it in what comes next.\n\n_In case you haven't your Astra DB yet, go ahead and create it now for free by clicking here:_\n\n\u003ca href=\"https://astra.dev/yt-01-25-23\"\u003e\u003cimg src=\"images/create_astra_db_button.png?raw=true\" /\u003e\u003c/a\u003e\n\n\u003e _Tip_: call the database `workshops` and the keyspace `sensor_data`.\n\n_In case you already have a database `workshops` but no `sensor_data` keyspace, simply add it using the \"Add Keyspace\" button on the bottom right hand corner of your DB dashboard: please do so, avoiding the creation of another database with the same name. (Also, on the free tier you have to \"Resume\" the database if it is \"Hibernated\" for prolonged inactivity.)_\n\n## 1. Setup\n\n### Astra DB \"Administrator\" token\n\nIf you don't have a \"DB Administrator\" token yet, log in to your Astra DB\nand create a token with this role.\nTo create the token, click on the \"...\" menu next to your database in the main\nAstra dashboard and choose \"Generate token\". Then make sure you select the \"DB Administrator\" role.\n_Download or note down all components of the token before navigating away:\nthese will not be shown again._\n[See here](https://awesome-astra.github.io/docs/pages/astra/create-token/)\nfor more on token creation.\n\n\u003e **⚠️ Important**\n\u003e ```\n\u003e The instructor will show the token creation on screen,\n\u003e but will then destroy it immediately for security reasons.\n\u003e ```\n\nMind that, as mentioned already, _the default Token auto-created for you when\ncreating the database is not powerful enough for us today._\n\n### Gitpod\n\nFirst, open this repo in Gitpod by right-clicking the following button (\"open in new tab\"):\n\n\u003ca href=\"https://gitpod.io/#https://github.com/datastaxdevs/workshop-cassandra-application-development\"\u003e\u003cimg src=\"images/open_in_gitpod.svg?raw=true\" /\u003e\u003c/a\u003e\n\nIn a couple of minutes you will have your Gitpod IDE up and running, with this repo cloned, ready and waiting for you (you may have to authorize the Gitpod single-sign-on to continue).\n\n\u003e You may see a dialog about \"opening this workspace in VS Code Desktop\": you can safely dismiss it.\n\n_Note_: The next steps are to be executed _within the Gitpod IDE._\n\n### Configure the Astra CLI\n\nAstra CLI is preinstalled: configure it by providing your\n`AstraCS:...` database token when prompted:\n\n```bash\nastra setup\n```\n\n(_Optional)_ Now you can use the CLI to get some info on your database(s):\n\n```bash\nastra db list\nastra db get workshops\n```\n\n\u003cdetails\u003e\u003csummary\u003eClick here if you have \u003cstrong\u003emultiple databases\u003c/strong\u003e called \"workshops\"\u003c/summary\u003e\n\nDB names are not required to be unique: what _is_ unique is the [\"Database ID\"](https://awesome-astra.github.io/docs/pages/astra/faq/#where-should-i-find-a-database-identifier).\n\nIn case you find yourself having more than one \"workshops\" database, you can provide the ID instead of the name to the CLI commands\nand, being able to unambiguously determine the target, it will work flawlessly.\n\n\u003c/details\u003e\n\n### Create and populate tables\n\nThe Astra CLI can also launch a `cqlsh` session for you, automatically connected to your database. Use this feature to execute a `cql` script that resets the contents of the `sensor_data` keyspace, creating the right tables and writing representative data on them:\n\n```bash\n# Make sure the DB exists (resuming it if hibernated)\nastra db create workshops -k sensor_data --if-not-exist --wait\n\n# Launch the initialization script\nastra db cqlsh workshops -f initialize.cql\n```\n\nYou are encouraged to peek at the contents of the script to see what it does.\n\n_(Optional)_ Interactively run some test queries on the newly-populated keyspace\n\n\u003cdetails\u003e\u003csummary\u003eClick to show test queries\u003c/summary\u003e\n\nOpen an interactive `cqlsh` shell with:\n\n```bash\nastra db cqlsh workshops -k sensor_data\n```\n\nNow you can copy-paste any of the queries below and execute them with the \u003ckbd\u003eEnter\u003c/kbd\u003e key:\n\n```sql\n-- Q1 (note 'all' is the only partition key in this table)\nSELECT  name, description, region, num_sensors\nFROM    networks\nWHERE   bucket = 'all';\n\n-- Q2\nSELECT  date_hour, avg_temperature, latitude, longitude, sensor\nFROM    temperatures_by_network\nWHERE   network    = 'forest-net'\n  AND   week       = '2020-07-05'\n  AND   date_hour \u003e= '2020-07-05'\n  AND   date_hour  \u003c '2020-07-07';\n\n-- Q3\nSELECT  *\nFROM    sensors_by_network\nWHERE   network = 'forest-net';\n\n-- Q4\nSELECT  timestamp, value\nFROM    temperatures_by_sensor\nWHERE   sensor = 's1003'\n  AND   date   = '2020-07-06';\n\n```\n\nTo close `cqlsh` and get back to the shell prompt, execute the `EXIT` command.\n\n\u003c/details\u003e\n\n### Prepare connection settings\n\nYou can use the Astra CLI to prepare a dotenv file which defines all connection\nparameters and secrets needed for your application to run:\n\n```bash\nastra db create-dotenv workshops -k sensor_data\n```\n\nA `.env` file will be created (you can peek at it with Gitpod's file editor, e.g. running `gp open .env`).\n\nYou can now source it with:\n\n```bash\nsource .env\n```\n\n\u003e **Note**: The `.env` is handled differently in each implementation (Java, Python, Javascript), as will be shown later.\n\u003e\n\u003e **Note**: While creating the `.env`, the database's [Secure Connect Bundle](https://awesome-astra.github.io/docs/pages/astra/download-scb/)\n\u003e has also been downloaded for you: you may want to check that the file\n\u003e is about 12-13 KiB in size with `ls $ASTRA_DB_SECURE_BUNDLE_PATH -lh`.\n\n## 2 \u0026 3. Now to the exercises!\n\n_Note: it is suggested to check the [sensor data model](https://www.datastax.com/learn/data-modeling-by-example/sensor-data-model) in order to be better prepared for what follows. Keep it open in another tab._\n\nChoose your path:\n\n- [Python](python/Python_README.md)\n- [Java](java/Java_README.md)\n- [Javascript](javascript/Javascript_README.md)\n\n## Homework instructions\n\n\u003cimg src=\"images/api-micro.png?raw=true\" width=\"150\" align=\"left\" /\u003e\n\nIn order to get a badge of completion for this workshop, complete the following assignment:\n\n\u003e Add a GET endpoint to your API corresponding to query `Q1`\n\u003e (_\"Find information about all networks; order by name (asc)\"_).\n\u003e **Tip**: remember the data-modeling optimization of having inserted the `bucket` column.\n\nTake a _screenshot_ of the relevant code block and of a successful request to that endpoint and head over to [this form](https://dtsx.io/homework-appdev). Answer a couple of \"theory\" questions, attach your screenshot, and hit \"Submit\".\n\nThat's it! Expect to be awarded your badge in the next week or so!\n\n## Conclusion\n\nThis is not the end of your journey, rather the start: come visit us for more cool content, and learn how to succeed using Cassandra and Astra DB in your applications!\n\nCongratulations and see you at our next workshop!\n\n\u003e Sincerely yours, the DataStax Developers\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatastaxdevs%2Fworkshop-cassandra-application-development","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatastaxdevs%2Fworkshop-cassandra-application-development","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatastaxdevs%2Fworkshop-cassandra-application-development/lists"}