Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,19 @@ import streamlit as st
|
|
| 2 |
import firebase_admin
|
| 3 |
from firebase_admin import credentials
|
| 4 |
from firebase_admin import firestore
|
|
|
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
@st.experimental_singleton
|
| 8 |
def get_db_firestore():
|
|
@@ -30,7 +42,12 @@ def selectCollectionDocument(collection, document):
|
|
| 30 |
st.write("The id is: ", doc.id)
|
| 31 |
st.write("The contents are: ", doc.to_dict())
|
| 32 |
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
st.write("singleton stateful connection to cloud firestore")
|
| 35 |
st.write(u"spin up some awesome 🤯 - episodic and semantic memory 🧠 for AI - here we come")
|
| 36 |
db = get_db_firestore()
|
|
|
|
| 2 |
import firebase_admin
|
| 3 |
from firebase_admin import credentials
|
| 4 |
from firebase_admin import firestore
|
| 5 |
+
from datetime import datetime
|
| 6 |
|
| 7 |
+
now = datetime.now() # current date and time
|
| 8 |
+
year = now.strftime("%Y")
|
| 9 |
+
st.write("year:", year)
|
| 10 |
+
month = now.strftime("%m")
|
| 11 |
+
st.write(""month:", month)
|
| 12 |
+
day = now.strftime("%d")
|
| 13 |
+
st.write(""day:", day)
|
| 14 |
+
time = now.strftime("%H:%M:%S")
|
| 15 |
+
st.write(""time:", time)
|
| 16 |
+
date_time = now.strftime("%m/%d/%Y, %H:%M:%S")
|
| 17 |
+
st.write(""date and time:",date_time)
|
| 18 |
|
| 19 |
@st.experimental_singleton
|
| 20 |
def get_db_firestore():
|
|
|
|
| 42 |
st.write("The id is: ", doc.id)
|
| 43 |
st.write("The contents are: ", doc.to_dict())
|
| 44 |
|
| 45 |
+
#add data to the beastie with a generic reusable upsert function
|
| 46 |
+
def upsertdate(collection, document, firefield, first, last, born):
|
| 47 |
+
doc_ref = db.collection(collection).document(document)
|
| 48 |
+
doc_ref.set({u'firefield': firefield, u'first': first, u'last': last, u'born': born
|
| 49 |
+
})
|
| 50 |
+
|
| 51 |
st.write("singleton stateful connection to cloud firestore")
|
| 52 |
st.write(u"spin up some awesome 🤯 - episodic and semantic memory 🧠 for AI - here we come")
|
| 53 |
db = get_db_firestore()
|