File tree Expand file tree Collapse file tree 1 file changed +4
-26
lines changed Expand file tree Collapse file tree 1 file changed +4
-26
lines changed Original file line number Diff line number Diff line change 1
- import os
2
- from pathlib import Path
3
- import ssl
4
- import tempfile
5
- import urllib .request
6
-
7
- from pyarrow import flight
8
-
9
-
10
- # Check for gRPC certificates
11
- if not (Path (Path .cwd ().absolute ().anchor ) / 'usr' / 'share' / 'grpc' / 'roots.pem' ).exists ():
12
- env_name = "GRPC_DEFAULT_SSL_ROOTS_FILE_PATH"
13
- if env_name not in os .environ or not Path (os .environ [env_name ]).exists ():
14
- tls_root_certs = Path (tempfile .gettempdir ()) / "isrgrootx1.pem"
15
- if not Path (tls_root_certs ).exists ():
16
- ssl ._create_default_https_context = ssl ._create_unverified_context
17
- urllib .request .urlretrieve ("https://letsencrypt.org/certs/isrgrootx1.pem" , str (tls_root_certs ))
18
- os .environ [env_name ] = str (tls_root_certs )
19
-
20
- client = flight .connect ('grpc+tls://flight.spiceai.io' )
21
- headers = [client .authenticate_basic_token ('' , 'API_KEY' )]
22
- options = flight .FlightCallOptions (headers = headers )
23
-
24
- query = 'SELECT * FROM eth.blocks ORDER BY number DESC LIMIT 10;'
25
- flight_info = client .get_flight_info (flight .FlightDescriptor .for_command (query ), options )
26
- reader = client .do_get (flight_info .endpoints [0 ].ticket , options )
1
+ # Install with: pip install git+https://github.com/spicehq/spice-py
2
+ from spicepy import Client
27
3
4
+ client = Client ('API_KEY' )
5
+ reader = client .query ('SELECT * FROM eth.recent_blocks ORDER BY number DESC;' )
28
6
print (reader .read_pandas ())
You can’t perform that action at this time.
0 commit comments