[英]How do I pass a string to a boto3 function in IPython from a Jupyter notebook?
I am setting up an environment in Jupyter that allows a user to query their Database Schema from AWS Glue. 我在Jupyter中设置了一个环境,允许用户从AWS Glue查询他们的数据库模式。 The Jupyter line magic accepts 2 arguments: the database name, and the table name.
Jupyter line magic接受2个参数:数据库名称和表名。
These arguments are then parsed with split(), and separated into two arguments: database, and table. 然后使用split()解析这些参数,并将其分为两个参数:database和table。
What would be the best way to pass these to the glue.get_table call? 将这些传递给glue.get_table调用的最佳方法是什么? Which accepts 2 argument which I was previously explicitly declaring in the code?
哪个接受我之前在代码中明确声明的2个参数?
I'm fairly new to Python and may be missing an obvious answer here, but I'm currently passing them as string variables. 我对Python很新,可能在这里错过了一个明显的答案,但我现在将它们作为字符串变量传递。
@line_magic('describe') def describe(self, line, local_ns = None): @line_magic('describe')def describe(self,line,local_ns = None):
database = line.split(" ")[0]
view = line.split(" ")[1]
glue = boto3.client('glue', region_name=ec2_metadata.region)
response = glue.get_table(DatabaseName='%s', Name='%s' % (database, view))
I am expecting to see these values passed into boto as if I were to write them in myself, but I am seeing 我希望看到这些值传递给boto,就像我自己写的那样,但我看到了
TypeError: not all arguments converted during string formatting TypeError:并非在字符串格式化期间转换所有参数
being thrown on the glue.get_table() function 被抛到glue.get_table()函数上
尝试这个:
response = glue.get_table(DatabaseName=database, Name=view)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.