forked from TrueCloudLab/frostfs-s3-gw
Initial commit based on https://github.com/minio/minio/releases/tag/RELEASE.2020-07-02T00-15-09Z
This commit is contained in:
commit
9bf57615b0
1206 changed files with 281445 additions and 0 deletions
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'])
|
Loading…
Add table
Add a link
Reference in a new issue