Giter VIP home page Giter VIP logo

azure-cosmos-db-cassandra-python-getting-started's Introduction

page_type languages products description urlFragment
sample
python
azure
Azure Cosmos DB is Microsoft's globally distributed multi-model database service.
azure-cosmos-db-cassandra-python-getting-started

Accessing Cassandra API on Azure Cosmos DB using Python

Azure Cosmos DB is Microsoft's globally distributed multi-model database service. You can quickly create and query document, table, key-value, and graph databases, all of which benefit from the global distribution and horizontal scale capabilities at the core of Azure Cosmos DB. This quick start demonstrates how to create an Azure Cosmos DB account for the Cassandra API by using the Azure portal. You'll then build a user profile console app, output as shown in the following image, with sample data.

Running this sample

  1. Clone this repository using git clone [email protected]:Azure-Samples/Azure-Samples/azure-cosmos-db-cassandra-python-getting-started.git cosmosdb.

  2. Change directories to the repo using cd cosmosdb

  3. Next, substitute the contactPoint, username, password in config.py with your Cosmos DB account's values from connectionstring panel of the portal.

    'username': '<FILLME>',
    'password': '<FILLME>',
    'contactPoint': '<FILLME>',
    'port':'10350'
    
  4. Run

    pip install Cassandra-driver 
    pip install prettytable
    pip install requests
    pip install pyopenssl
    

    in a terminal to install required python packages

  5. Run python pyquickstart.py in a terminal to execute it.

About the code

The code included in this sample is intended to get you quickly started with a python program that connects to Azure Cosmos DB with the Cassandra API.

More information

azure-cosmos-db-cassandra-python-getting-started's People

Contributors

iriaosara avatar kanshig avatar kansrini avatar microsoftopensource avatar mimig1 avatar msftgits avatar snehagunda avatar spelluru avatar zanasrin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-cosmos-db-cassandra-python-getting-started's Issues

Error in insert into example

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Example data of pyquickstart.py

Any log messages given by the failure

Traceback (most recent call last):
File "D:/Desarrollo/azure-cosmos-db-cassandra-python-getting-started/pyquickstart.py", line 38, in
insert_data = session.prepare("INSERT INTO uprofile.user (user_id, user_name , user_bcity) VALUES (?,?,?)")
File "cassandra\cluster.py", line 3069, in cassandra.cluster.Session.prepare
File "cassandra\cluster.py", line 3066, in cassandra.cluster.Session.prepare
File "cassandra\cluster.py", line 4871, in cassandra.cluster.ResponseFuture.result
File "cassandra\connection.py", line 1075, in cassandra.connection.Connection.process_msg
File "cassandra\protocol.py", line 1189, in cassandra.protocol._ProtocolHandler.decode_message
File "cassandra\protocol.py", line 740, in cassandra.protocol.ResultMessage.recv_body
File "cassandra\protocol.py", line 730, in cassandra.protocol.ResultMessage.recv
File "cassandra\protocol.py", line 771, in cassandra.protocol.ResultMessage.recv_results_prepared
File "cassandra\protocol.py", line 815, in cassandra.protocol.ResultMessage.recv_prepared_metadata
File "cassandra\protocol.py", line 1287, in cassandra.protocol.read_short
File "D:\Programas\Anaconda3\envs\tf-gpu\lib\site-packages\cassandra\marshal.py", line 22, in
unpack = lambda s: packer.unpack(s)[0]
struct.error: unpack requires a buffer of 2 bytes

Expected/desired behavior

Insert and show records in cmd

OS and Version?

Windows 10

Versions

Using PyCharm and VS Code


Thanks! We'll be in touch soon.

unpack requires a buffer of 2 bytes

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

clone and run project

Any log messages given by the failure

Exception has occurred: error unpack requires a buffer of 2 bytes

Expected/desired behavior

No error

OS and Version?

Windows 10.

Versions

1909

Mention any other details that might be useful

Error happens on line 38 when tying to exectute this insert_data = session.prepare("INSERT INTO uprofile.user (user_id, user_name , user_bcity) VALUES (?,?,?)")


Thanks! We'll be in touch soon.

Specify Cassandra protocol to use

This issue is for a: (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Expected/desired behavior

The example should specify the protocol to be used. It defaults to DSE_v2, which disables client-side timestamp generation and possibly causes other confusion. The correct connection line is as follows:

cluster = Cluster([cfg.config['contactPoint']], port = cfg.config['port'], auth_provider=auth_provider,ssl_context=ssl_context,protocol_version=ProtocolVersion.V4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.