From b694579d20c96290425b105e2f04e143bf0ea1c9 Mon Sep 17 00:00:00 2001 From: Priec Date: Mon, 16 Mar 2026 21:57:23 +0100 Subject: [PATCH] fetch db structure --- fastapi_proj/.gitignore | 2 ++ fastapi_proj/main.py | 16 +++++++++++ flake.lock | 61 +++++++++++++++++++++++++++++++++++++++++ flake.nix | 45 ++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 fastapi_proj/.gitignore create mode 100644 fastapi_proj/main.py create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/fastapi_proj/.gitignore b/fastapi_proj/.gitignore new file mode 100644 index 0000000..ac5cc2e --- /dev/null +++ b/fastapi_proj/.gitignore @@ -0,0 +1,2 @@ +kysuce-vyuka-firestore-21b77f3ea979.json +*.json diff --git a/fastapi_proj/main.py b/fastapi_proj/main.py new file mode 100644 index 0000000..7bbfb60 --- /dev/null +++ b/fastapi_proj/main.py @@ -0,0 +1,16 @@ +from google.cloud import firestore + +db = firestore.Client.from_service_account_json('fastapi-firestore-filipriec-824499994d80.json') + + +# Get all collections +print("Collections:") +for col in db.collections(): + print(f" - {col.id}") + + # Get first document to see fields + docs = list(col.limit(1).stream()) + if docs: + print(f" Fields: {list(docs[0].to_dict().keys())}") + print(f" Example: {docs[0].to_dict()}") + print() diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1f675e1 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1773646010, + "narHash": "sha256-iYrs97hS7p5u4lQzuNWzuALGIOdkPXvjz7bviiBjUu8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5b2c2d84341b2afb5647081c1386a80d7a8d8605", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..8f6d953 --- /dev/null +++ b/flake.nix @@ -0,0 +1,45 @@ +{ + description = "FastAPI with Cloud Firestore development environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + + # Python with required packages + pythonEnv = pkgs.python312.withPackages (ps: with ps; [ + fastapi + uvicorn + google-cloud-firestore + pydantic + python-dotenv + ]); + in + { + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + pythonEnv + git + curl + ]; + + shellHook = '' + echo "FastAPI + Firestore development environment" + echo "" + echo "Python: $(python --version)" + echo "Packages: fastapi, uvicorn, google-cloud-firestore, pydantic" + echo "" + echo "Quick start:" + echo " 1. Place your serviceAccountKey.json in this directory" + echo " 2. Create main.py with your FastAPI app" + echo " 3. Run: uvicorn main:app --reload" + echo "" + ''; + }; + }); +}