惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
GbyAI
GbyAI
SecWiki News
SecWiki News
Project Zero
Project Zero
C
Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Scott Helme
Scott Helme
A
Arctic Wolf
Security Latest
Security Latest
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
Apple Machine Learning Research
Apple Machine Learning Research
T
Tailwind CSS Blog
The Hacker News
The Hacker News
T
Tenable Blog
雷峰网
雷峰网
有赞技术团队
有赞技术团队
V
V2EX
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threat Research - Cisco Blogs
T
Threatpost
AWS News Blog
AWS News Blog
L
LINUX DO - 热门话题
Application and Cybersecurity Blog
Application and Cybersecurity Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
SegmentFault 最新的问题
月光博客
月光博客
Spread Privacy
Spread Privacy
S
Secure Thoughts
宝玉的分享
宝玉的分享
博客园 - 三生石上(FineUI控件)
Forbes - Security
Forbes - Security
T
The Exploit Database - CXSecurity.com
G
GRAHAM CLULEY
The Last Watchdog
The Last Watchdog
Y
Y Combinator Blog
I
Intezer
博客园 - 【当耐特】
B
Blog RSS Feed
Attack and Defense Labs
Attack and Defense Labs
I
InfoQ
博客园 - 叶小钗
Cyberwarzone
Cyberwarzone
V2EX - 技术
V2EX - 技术
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
H
Help Net Security
C
CERT Recently Published Vulnerability Notes

Supabase Blog

AI Agents Know About Supabase. They Don't Always Use It Right. Custom OIDC Providers for Supabase Auth 100,000 GitHub stars Supabase docs over SSH Navigating Regional Network Blocks Supabase Joins the Stripe Projects Developer Preview Log Drains: Now available on Pro Supabase Storage: major performance, security, and reliability updates Supabase incident on February 12, 2026 Hydra joins Supabase X / Twitter OAuth 2.0 is now available for Supabase Auth BKND joins Supabase Supabase is now an official Claude connector Supabase PrivateLink is now available Introducing: Postgres Best Practices When to use Read Replicas vs. bigger compute Introducing TRAE SOLO integration with Supabase Supabase Security Retro: 2025 Sync Stripe Data to Your Supabase Database in One Click Building ChatGPT Apps with Supabase Edge Functions and mcp-use Own Your Observability: Supabase Metrics API Introducing iceberg-js: A JavaScript Client for Apache Iceberg Introducing Supabase for Platforms Adding Async Streaming to Postgres Foreign Data Wrappers Build "Sign in with Your App" using Supabase Auth Introducing Seven New Email Templates for Supabase Auth The new Supabase power for Kiro Introducing Supabase ETL Introducing Analytics Buckets Introducing Vector Buckets Snap, Inc. Launches Snap Cloud, Powered by Supabase Triplit joins Supabase Supabase Series E 1000 Y Combinator Founders Choose Supabase gm 👋 web3, welcome aboard to Sign in with Web3 (Solana, Ethereum) Announcing the Supabase Remote MCP Server Enterprise speed, enterprise standards with Bolt Cloud + Supabase PostgREST 13 Lovable Cloud + Supabase: The Default Platform for AI Builders Processing large jobs with Edge Functions, Cron, and Queues Defense in Depth for MCP Servers OrioleDB Patent: now freely available to the Postgres community Supabase Launch Week 15 Hackathon Winner Announcement The Vibe Coder's Guide to Supabase Environments Testing for Vibe Coders: From Zero to Production Confidence The Vibe Coding Master Checklist Vibe Coding: Best Practices for Prompting Supabase Auth: Build vs. Buy Top 10 Launches of Launch Week 15 Supabase Launch Week 15 Hackathon Storage: 10x Larger Uploads, 3x Cheaper Cached Egress, and 2x Egress Quota Persistent Storage and 97% Faster Cold Starts for Edge Functions Algolia Connector for Supabase New Observability Features in Supabase Improved Security Controls and A New Home for Security Introducing Branching 2.0 Stripe-To-Postgres Sync Engine as standalone Library Supabase Analytics Buckets with Iceberg Support Create a Supabase backend using Figma Make Introducing JWT Signing Keys Supabase UI: Platform Kit Build a Personalized AI Assistant with Postgres Announcing Multigres: Vitess for Postgres Building on open table formats Open Data Standards: Postgres, OTel, and Iceberg Simplifying back-end complexity with Supabase Data APIs PostgreSQL Event Triggers without superuser access Top 10 Launches of Launch Week 14 Supabase MCP Server Data API Routes to Nearest Read Replica Declarative Schemas for Simpler Database Management Realtime: Broadcast from Database Keeping Tabs on What's New in Supabase Studio Edge Functions: Deploy from the Dashboard + Deno 2.1 Automatic Embeddings in Postgres Introducing the Supabase UI Library Supabase Auth: Bring Your Own Clerk Postgres Language Server: Initial Release Migrating from Fauna to Supabase Migrating from the MongoDB Data API to Supabase Dedicated Poolers Postgres as a Graph Database: (Ab)using pgRouting AI Hackathon at Y Combinator Calendars in Postgres using Foreign Data Wrappers Supabase Launch Week 13 Hackathon Winners How to Hack the Base! Running Durable Workflows in Postgres using DBOS database.build v2: Bring-your-own-LLM Restore to a New Project Hack the Base! with Supabase Top 10 Launches of Launch Week 13 Supabase Queues High Performance Disk Supabase Cron Supabase CLI v2: Config as Code Supabase Edge Functions: Introducing Background Tasks, Ephemeral Storage, and WebSockets Supabase AI Assistant v2 OrioleDB Public Alpha Executing Dynamic JavaScript Code on Supabase with Edge Functions ClickHouse Partnership, improved Postgres Replication, and Disk Management
Python data loading with Supabase
Ant Wilson · 2022-06-17 · via Supabase Blog

Python data loading with Supabase

Python is an excellent choice when it comes to data science. With a wide selection of libraries and built-in analytics tools, you can crunch data with ease, analyze even the most complex datasets, and visualize your results in beautiful charts and graphs.

Supabase is backend-as-a-service built on top of PostgreSQL. It's an excellent choice for building modern data-intensive apps and tooling.

Thanks to our incredible community, Supabase now has a powerful and open source Python SDK. With Supabase and Python, you can automate tasks such as CRUD operations with only a few lines of code. This guide will first create a simple schema in Supabase, then we'll use the Supabase Python SDK to show how you can load sample data.

Before we dive in, let's look at some prerequisites you'll need:

  • Python version > 3.7
    • The SDK only supports version > 3.7. You can download a supported Python version from here.
  • Python virtual environment
    • This is optional, but it will avoid issues of package dependencies and version conflicts. You can find the steps to create a virtual environment here. We will be using PyCharm to harness its venv creation capabilities.
  • Faker python package
    • We will be using the faker-commerce package from the Faker library in Python to generate realistic sample data.

Supabase is built for developers, and you can get started for free using your existing GitHub account. Once your Supabase account is set up, you will access the Supabase dashboard. From here, go to All Project > New Project.

Give your project a name and set the database password. You can also choose the region and adjust the pricing plan based on the requirements of your project.

Your project will spin up within 2 minutes.

In this example, we'll be creating 2 tables in Supabase:

  • Vendor (fields are vendor_name, vendor_location, and total_employees)
  • Product (vendor_id as FK, product_name, price, and total orders)

The database schema will look like the following:

Let us now begin creating the tables. Once you create a project, you will need to go to Table Editor > New Table

Now, you can create a table according to the defined schema.

Click on Save to create your vendor table. Similarly, create the product table.

Before you click Save, you need to set up the foreign key relationship between the Product and Vendor table. To do this, select the button next to “vendor_id”

Select the vendor_id primary key from the “Vendor” table.

Click on Save and you are good to go. You should now see the 2 tables under Table Editor.

Once you have set up the tables and installed the prerequisites, you can now start playing around with the Python SDK. To install the SDK, run the following command:

pip3 install supabase

Ensure that you are running this inside your python virtual environment. This will take a few minutes to complete.

The SDK authentication uses API keys pointing to a project URL. To find out your project URL and APIs, go to Settings > API.

API credentials and project URL can be stored in environment variables. Setting the environment variables in bash/zsh is very simple. All we need to do is run:


_10

export <variable_name>=<variable_value>


So for our example we will set them up like this:


_10

export SUPABASE_URL=<<the value under config > URL>>

_10

export SUPABASE_KEY=<<the value present in Project API keys > anon public>>

_10

export SUPABASE_SECRET_KEY=<<the value present in Project API keys > service_role secret>>


Here is a snippet of the code we will be using to insert random data into our tables:


_50

import os

_50

import json

_50

from dotenv import load_dotenv

_50

from supabase import create_client, Client

_50

from faker import Faker

_50

import faker_commerce

_50

_50

_50

def add_entries_to_vendor_table(supabase, vendor_count):

_50

fake = Faker()

_50

foreign_key_list = []

_50

fake.add_provider(faker_commerce.Provider)

_50

main_list = []

_50

for i in range(vendor_count):

_50

value = {'vendor_name': fake.company(), 'total_employees': fake.random_int(40, 169),

_50

'vendor_location': fake.country()}

_50

_50

main_list.append(value)

_50

data = supabase.table('Vendor').insert(main_list).execute()

_50

data_json = json.loads(data.json())

_50

data_entries = data_json['data']

_50

for i in range(len(data_entries)):

_50

foreign_key_list.append(int(data_entries[i]['vendor_id']))

_50

return foreign_key_list

_50

_50

_50

def add_entries_to_product_table(supabase, vendor_id):

_50

fake = Faker()

_50

fake.add_provider(faker_commerce.Provider)

_50

main_list = []

_50

iterator = fake.random_int(1, 15)

_50

for i in range(iterator):

_50

value = {'vendor_id': vendor_id, 'product_name': fake.ecommerce_name(),

_50

'inventory_count': fake.random_int(1, 100), 'price': fake.random_int(45, 100)}

_50

main_list.append(value)

_50

data = supabase.table('Product').insert(main_list).execute()

_50

_50

_50

def main():

_50

vendor_count = 10

_50

load_dotenv()

_50

url: str = os.environ.get("SUPABASE_URL")

_50

key: str = os.environ.get("SUPABASE_KEY")

_50

supabase: Client = create_client(url, key)

_50

fk_list = add_entries_to_vendor_table(supabase, vendor_count)

_50

for i in range(len(fk_list)):

_50

add_entries_to_product_table(supabase, fk_list[i])

_50

_50

_50

main()


To summarize what we have done using this code snippet:

  • We have inserted 10 random vendors to the table.
  • For each of the 10 vendors, we have inserted a number of different products

Data can also be viewed directly from the Supabase dashboard. To do this, go to Table Editor > All tables

Note: In case you cannot see any of the data, you should hit the Refresh button.

With Python, data loading into Supabase is easy. It just takes a few easy steps to get started with the Python SDK and Supabase. In the next part of this blog series, we will learn how to visualize the data that we just loaded into Supabase using Metabase. Stay tuned!

If you have any questions please reach out via Twitter or join our Discord.