0

I have a sqlLite db file that is reside in S3 bucket. I am trying to read the information (mainly read) from the tables to be transform to json. I saw the nodejs with sqlite3 but somehow I can see to make it work on lambda.

const fs = require('fs')
const AWS = require('aws-sdk');
const s3 = new AWS.S3();

exports.handler = async (event, context) => {
    const stream = fs.createWriteStream(`/tmp/test.db`, {flags:'a'});
    const download = async (args, stream) => {
        const params = {
            Bucket: 'xyzBucket',
            Key: 'test.db'
        };
        const readStream = s3.getObject(params).createReadStream();
     
        const res = await readStream.pipe(stream)


    }

};
John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • Yes its possible to read db file from s3 and also perform operations. – Ajay Managaon Jun 26 '23 at 03:39
  • Amazon S3 objects are read-only. If you want to modify the contents of an object in S3, you will need to upload a new file with the same Key (filename). Therefore, your best option is to download the object from S3 into the Lambda function's `/tmp/` directory and use it locally. – John Rotenstein Jun 26 '23 at 04:59
  • Thank you. Do you happen to have any code I can refer to? So far I can't download the object to /tmp/ folder. – RainbowSong Jul 05 '23 at 02:16

0 Answers0