fetch db structure
This commit is contained in:
2
fastapi_proj/.gitignore
vendored
Normal file
2
fastapi_proj/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
kysuce-vyuka-firestore-21b77f3ea979.json
|
||||||
|
*.json
|
||||||
16
fastapi_proj/main.py
Normal file
16
fastapi_proj/main.py
Normal file
@@ -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()
|
||||||
61
flake.lock
generated
Normal file
61
flake.lock
generated
Normal file
@@ -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
|
||||||
|
}
|
||||||
45
flake.nix
Normal file
45
flake.nix
Normal file
@@ -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 ""
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user