【问题标题】:Spark + cassandra : how to create a keyspace?Spark + cassandra:如何创建键空间?
【发布时间】:2017-04-28 19:00:18
【问题描述】:

我正在通过pyspark_cassandra

但我看不到任何创建表/键空间的方法 => 有可能吗?

如果是这样,怎么做?

【问题讨论】:

    标签: apache-spark cassandra


    【解决方案1】:

    也许你可以试试这个包?

    这个包来自DataStax,它是python的Cassandra驱动程序。

    Github: https://github.com/datastax/python-driver

    API 文档: https://datastax.github.io/python-driver/api/cassandra/cluster.html

    from cassandra.cluster import Cluster
    cluster = Cluster(['your_cassandra_ip'])
    session = cluster.connect()
    
    session.execute('CREATE KEYSPACE IF NOT EXISTS mykeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };')
    

    【讨论】:

      猜你喜欢
      • 2015-08-22
      • 2013-01-02
      • 1970-01-01
      • 2019-03-01
      • 2019-08-11
      • 1970-01-01
      • 2020-10-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多