File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ import dlt
2
+
3
+ from cassandra .auth import PlainTextAuthProvider # type: ignore
4
+ from cassandra .cluster import Cluster # type: ignore
5
+
6
+
7
+ @dlt .source (max_table_nesting = 0 )
8
+ def cassandra_source (
9
+ host : str ,
10
+ port : int ,
11
+ keyspace : str | None = None ,
12
+ table : str | None = None ,
13
+ username : str | None = None ,
14
+ password : str | None = None ,
15
+ ):
16
+ @dlt .resource ()
17
+ def fetch_data ():
18
+ auth_provider = PlainTextAuthProvider (username = username , password = password )
19
+ cluster = Cluster (contact_points = [host ], port = port , auth_provider = auth_provider )
20
+ session = cluster .connect (keyspace )
21
+
22
+ rows = session .execute (f"SELECT * FROM { table } " )
23
+
24
+ for row in rows :
25
+ yield row
26
+
27
+ return fetch_data
You can’t perform that action at this time.
0 commit comments