Cassandra: The Definitive Guide: Distributed Data at Web Scale by Jeff Carpenter & Eben Hewitt
Author:Jeff Carpenter & Eben Hewitt [Carpenter, Jeff]
Language: eng
Format: azw3
Publisher: O'Reilly Media
Published: 2016-06-29T04:00:00+00:00
Simple statement
Thankfully, we needn’t make things so hard on ourselves. The Java driver provides the SimpleStatement class to help construct parameterized statements. As it turns out, the execute() operation we saw before is actually a convenience method for creating a SimpleStatement.
Let’s try building a query by asking our Session object to create a SimpleStatement. Here’s an example of a statement that will insert a row in our hotels table, which we can then execute:
SimpleStatement hotelInsert = session.newSimpleStatement( "INSERT INTO hotels (hotel_id, name, phone) VALUES (?, ?, ?)", "AZ123", "Super Hotel at WestWorld", "1-888-999-9999"); session.execute(hotelInsert);
The first parameter to the call is the basic syntax of our query, indicating the table and columns we are interested in. The question marks are used to indicate values that we’ll be providing in additional parameters. We use simple strings to hold the values of the hotel ID, name, and phone number.
If we’ve created our statement correctly, the insert will execute successfully (and silently). Now let’s create another statement to read back the row we just inserted:
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8308)
Azure Data and AI Architect Handbook by Olivier Mertens & Breght Van Baelen(6784)
Building Statistical Models in Python by Huy Hoang Nguyen & Paul N Adams & Stuart J Miller(6758)
Serverless Machine Learning with Amazon Redshift ML by Debu Panda & Phil Bates & Bhanu Pittampally & Sumeet Joshi(6644)
Data Wrangling on AWS by Navnit Shukla | Sankar M | Sam Palani(6431)
Driving Data Quality with Data Contracts by Andrew Jones(6371)
Machine Learning Model Serving Patterns and Best Practices by Md Johirul Islam(6132)
Learning SQL by Alan Beaulieu(6003)
Weapons of Math Destruction by Cathy O'Neil(5794)
Big Data Analysis with Python by Ivan Marin(5385)
Data Engineering with dbt by Roberto Zagni(4389)
Solidity Programming Essentials by Ritesh Modi(4038)
Time Series Analysis with Python Cookbook by Tarek A. Atwan(3897)
Pandas Cookbook by Theodore Petrou(3598)
Blockchain Basics by Daniel Drescher(3304)
Hands-On Machine Learning for Algorithmic Trading by Stefan Jansen(2914)
Feature Store for Machine Learning by Jayanth Kumar M J(2819)
Learn T-SQL Querying by Pam Lahoud & Pedro Lopes(2801)
Mastering Python for Finance by Unknown(2748)
