0
下のコードがうまく動作し、ローカルマシンにXMLファイルが作成されています。しかし、私はラムダでこの機能を実行して、s3バケットのフォルダにXMLファイルを書きたいと思っています。私はAWSサービスに非常に慣れています。Amazon Lambdaを使用してS3にXMLファイルを書き込む方法
import pymysql
def query_db(outfileName):
outfile = file(outfileName, 'w')
connection = pymysql.connect(
host='XXXXXX',
user='XXXXXX',
password='XXXXX',
database='XXXXX',
)
cursor = connection.cursor()
cursor.execute("select title from table1;")
rows = cursor.fetchall()
outfile.write('<?xml version="1.0" encoding="utf-8"?>\n')
outfile.write('<source>\n')
for row in rows:
outfile.write(' <job>\n')
outfile.write(' <title><![CDATA[%s]]></title>\n' % row[0])
outfile.write(' </job>\n')
outfile.write('</source>\n')
outfile.close()
query_db('data.xml')
「IOError:[Errno 30]読み取り専用ファイルシステム: '\ tmp \\ data.xml' –
私の悪いです!huhu他にもスラッシュを入れます方法の前に –