From b08c47476d38aef26c95208bab54e370bcc92bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=BA=C5=A1=20Juraj=20Koby=C4=BEan?= Date: Sun, 24 Nov 2024 21:36:53 +0100 Subject: [PATCH] Get video in bucket and insert into DB --- storage_to_db.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 storage_to_db.py diff --git a/storage_to_db.py b/storage_to_db.py new file mode 100644 index 0000000..0e18ade --- /dev/null +++ b/storage_to_db.py @@ -0,0 +1,34 @@ +from supabase import create_client, Client + +# RLS policy permissions required: +# buckets table permissions: select +# objects table permissions: none + +url: str = "" +key: str = "" +supabase: Client = create_client(url, key) + + +# List all objects in the 'video' bucket +# .from("bucket_name") +# .list("folder_name") +response = supabase.storage.from_("video").list("",{"limit": 1000}) + + +for video in response: + video_name = video['name'].replace('.mp4', '') + video_url = f"{url}/storage/v1/object/public/video/{video_name}.mp4" + + # print the video name and url with tabs + print(video_name, video_url, sep="\t") + + response = ( + # .table("table_name") + # .insert({"column_name": value}) + # .execute SQL query + supabase.table("Videa") + .insert({"label": video_name, "video_url": video_url}) + .execute() + ) + # print(response) + -- 2.45.2