mirror of
https://github.com/minio/minio.git
synced 2025-11-21 02:09:08 -05:00
Add select docs and fix return values for Select API (#6300)
This commit is contained in:
committed by
kannappanr
parent
3de5a3157f
commit
5a4a57700b
33
docs/select/select.py
Normal file
33
docs/select/select.py
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env/env python3
|
||||
import boto3
|
||||
|
||||
s3 = boto3.client('s3',
|
||||
endpoint_url='http://localhost:9000',
|
||||
aws_access_key_id='minio',
|
||||
aws_secret_access_key='minio123',
|
||||
region_name='us-east-1')
|
||||
|
||||
r = s3.select_object_content(
|
||||
Bucket='mycsvbucket',
|
||||
Key='sampledata/TotalPopulation.csv.gz',
|
||||
ExpressionType='SQL',
|
||||
Expression="select * from s3object s where s.Location like '%United States%'",
|
||||
InputSerialization={
|
||||
'CSV': {
|
||||
"FileHeaderInfo": "USE",
|
||||
},
|
||||
'CompressionType': 'GZIP',
|
||||
},
|
||||
OutputSerialization={'CSV': {}},
|
||||
)
|
||||
|
||||
for event in r['Payload']:
|
||||
if 'Records' in event:
|
||||
records = event['Records']['Payload'].decode('utf-8')
|
||||
print(records)
|
||||
elif 'Stats' in event:
|
||||
statsDetails = event['Stats']['Details']
|
||||
print("Stats details bytesScanned: ")
|
||||
print(statsDetails['BytesScanned'])
|
||||
print("Stats details bytesProcessed: ")
|
||||
print(statsDetails['BytesProcessed'])
|
||||
Reference in New Issue
Block a user