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) +