Skip to content

Commit 5cad692

Browse files
author
corentin
committed
Change pyarrow to spicepy
1 parent a7cedf5 commit 5cad692

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

snippet.py

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,5 @@
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+
from spicepy import Client
272

3+
client = Client('API_KEY')
4+
reader = client.query('SELECT * FROM eth.blocks ORDER BY number DESC LIMIT 10;')
285
print(reader.read_pandas())

0 commit comments

Comments
 (0)