如何将 Anaconda 中的 Jupyter notebook 中的 Cassandra 连接到 Python?
How to connect Cassandra in Jupyter notebook In Anaconda with Python?
我正在尝试在我的计算机上使用 Cassandra。我做了什么:
! pip install cassandra-driver
已成功安装 cassandra-driver-3.24.0 geomet-0.2.1.post1
import Cassandra
创建到数据库的连接
然后连接数据库
from cassandra.cluster import Cluster
try:
cluster = Cluster(['127.0.0.1'])
session = cluster.connect()
except Exception as e:
print(e)
出现错误:
('Unable to connect to any servers', {'127.0.0.1:9042': ConnectionRefusedError(10061, "Tried connecting to [('127.0.0.1', 9042)]. Last error: No connection could be made because the target machine actively refused it")})
我想知道是不是配置有问题,于是我在下面查看:
Java_Hone 的用户变量如下:
Cassandra 安装在这里:
C:\Users\xx\anaconda3\Lib\site-packages
site-packages下有两个包:
我已经检查了很多答案,但找不到解决方案。我不熟悉配置。有人可以帮忙吗?
谢谢。
我已经回答了你在 community.datastax.com 上 post 提出的同一个问题。
您正在连接到 localhost
上的集群,但 运行 上不存在,因此连接失败。您需要指定集群中节点的IP之一。
有关详细信息,请参阅我在 https://community.datastax.com/questions/9162/ 中对您的 post 的回答。干杯!
我已经为 Cassandra CQL 发布了一个 Jupyter 内核。参见 cqljupter。
最简单的方法:
! pip install cassandra-driver
然后连接到您的本地主机和所需的 space
from cassandra.cluster import Cluster
cluster = Cluster()
session = cluster.connect('keyspace')
我正在尝试在我的计算机上使用 Cassandra。我做了什么:
! pip install cassandra-driver
已成功安装 cassandra-driver-3.24.0 geomet-0.2.1.post1
import Cassandra
创建到数据库的连接
然后连接数据库
from cassandra.cluster import Cluster
try:
cluster = Cluster(['127.0.0.1'])
session = cluster.connect()
except Exception as e:
print(e)
出现错误:
('Unable to connect to any servers', {'127.0.0.1:9042': ConnectionRefusedError(10061, "Tried connecting to [('127.0.0.1', 9042)]. Last error: No connection could be made because the target machine actively refused it")})
我想知道是不是配置有问题,于是我在下面查看:
Java_Hone 的用户变量如下:
Cassandra 安装在这里:
C:\Users\xx\anaconda3\Lib\site-packages
site-packages下有两个包:
我已经检查了很多答案,但找不到解决方案。我不熟悉配置。有人可以帮忙吗? 谢谢。
我已经回答了你在 community.datastax.com 上 post 提出的同一个问题。
您正在连接到 localhost
上的集群,但 运行 上不存在,因此连接失败。您需要指定集群中节点的IP之一。
有关详细信息,请参阅我在 https://community.datastax.com/questions/9162/ 中对您的 post 的回答。干杯!
我已经为 Cassandra CQL 发布了一个 Jupyter 内核。参见 cqljupter。
最简单的方法:
! pip install cassandra-driver
然后连接到您的本地主机和所需的 space
from cassandra.cluster import Cluster
cluster = Cluster()
session = cluster.connect('keyspace')