Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from cassandra.cluster import Cluster
- from cassandra.auth import PlainTextAuthProvider
- import pandas as pd
- def pandas_factory(colnames, rows):
- return pd.DataFrame(rows, columns=colnames)
- cluster = Cluster(
- contact_points=['127.0.0.1'],
- auth_provider = PlainTextAuthProvider(username='cassandra', password='cassandra')
- )
- session = cluster.connect()
- session.set_keyspace('giodevks')
- session.row_factory = pandas_factory
- session.default_fetch_size = 10000000 #needed for large queries, otherwise driver will do pagination. Default is 50000.
- rows = session.execute("""select * from my_table""")
- df = rows._current_rows
- print df.head()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement