Reputation: 609
Based on AWS TimeStream SDK documentation for Python, I have the following code:
import boto3
def list_databases(self):
print("Listing databases")
try:
result = self.client.list_databases(MaxResults=5)
self._print_databases(result['Databases'])
next_token = result.get('NextToken', None)
while next_token:
result = self.client.list_databases(NextToken=next_token, MaxResults=5)
self._print_databases(result['Databases'])
next_token = result.get('NextToken', None)
except Exception as err:
print("List databases failed:", err)
session = boto3.Session(profile_name='superuser', region_name='eu-west-1')
query_client = session.client('timestream-query')
list_databases(query_client)
The authentication for my user superuser
seems to work fine, but the boto3
session used for my query_client
does not have a client object:
Listing databases
List databases failed: 'TimestreamQuery' object has no attribute 'client'
What am I missing?
Upvotes: 0
Views: 654
Reputation: 7208
This argument name in this method is likely a mistake:
# this name is discouraged in non-OO code:
def list_databases(self):
self
is typically used in object oriented python code, which is not the case here.
Rename it as follows:
# this is better:
def list_databases(client):
Then, remove any mention of self
in the body of the function, for example:
# this is incorrect:
result = self.client.list_databases(MaxResults=5)
should be:
# this should work:
result = client.list_databases(MaxResults=5)
Upvotes: 1