Trying to open a file to read and another to write into using below syntax.
Not clear if the file will be read completely and written completely before inserting record into the table (docs) or it will read only the buffered size 1024, write into the (dest) file and create the row in the table.
Want to read many files in a folder/ subfolders and create entry for each file in the table.
Or is it advisable to read the file in chunks and add the chunks together and write in (dest) file at once ?
If I don't specify the buffer size, reading will be limited by available RAM in the disk.
with open(os.path.join(db_path,filename),'rb') as src, \
open(os.path.join(upload_folder,filename), 'wb') as dest:
for chunk in iter(lambda: src.read(4096), b' '):
dest.write(chunk)
if 1: # inserting record into a table
ins = docs.insert().values(
file_name = filename,
up_date=datetime.datetime.utcnow())
I have modfied with what I could understand from your comment. Can you please let me know if it is right now?