https://github.com/ajf1016/firestore-json-uploader
This Python script allows users to upload JSON data to a Firestore collection using the Firebase Admin SDK.
https://github.com/ajf1016/firestore-json-uploader
firebase python3
Last synced: 2 months ago
JSON representation
This Python script allows users to upload JSON data to a Firestore collection using the Firebase Admin SDK.
- Host: GitHub
- URL: https://github.com/ajf1016/firestore-json-uploader
- Owner: ajf1016
- Created: 2025-03-02T09:26:10.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-02T09:28:00.000Z (over 1 year ago)
- Last Synced: 2025-03-02T10:26:05.799Z (over 1 year ago)
- Topics: firebase, python3
- Language: Python
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Firestore JSON Uploader
## Overview
This Python script uploads JSON files to a Firestore collection using the Firebase Admin SDK. It is designed for users who need to batch-upload structured data into Firestore.
## Features
- Reads JSON files and uploads them to Firestore.
- Uses Firebase Admin SDK for authentication.
- Supports customizable Firestore collection and document structure.
- Skips missing files and logs progress.
## Prerequisites
- Python 3.x installed on your system.
- Firebase Admin SDK installed.
- A valid `serviceAccountKey.json` file for Firebase authentication.
## Installation
1. Clone the repository:
```bash
git clone https://github.com/yourusername/firestore-json-uploader.git
cd firestore-json-uploader
```
2. Install dependencies:
```bash
pip install firebase-admin
```
3. Place your Firebase service account key in the project directory and update the script:
```python
cred = credentials.Certificate("path/to/your/serviceAccountKey.json")
```
4. Modify the Firestore collection reference as needed:
```python
collection_ref = db.collection("your_collection").document("your_document").collection("your_subcollection")
```
## Usage
1. Add your JSON files (e.g., `document1.json`, `document2.json`, etc.) in the project directory.
2. Run the script:
```bash
python upload_to_firestore.py
```
3. The script will upload data and display progress logs.
## Notes
- Ensure your Firebase project is properly configured with Firestore.
- JSON files should have a structure compatible with Firestore.