Created
April 2, 2021 22:33
-
-
Save CoutinhoElias/3f1a6c0587128aebd1c4dc07515fa55b to your computer and use it in GitHub Desktop.
Adicionando dados no firebase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def exporta_produtos_json(self): | |
cred = credentials.Certificate('firebase-sdk.json') | |
default_app = firebase_admin.initialize_app(cred, { | |
'databaseURL': 'https://inventarioshop-8318f-default-rtdb.firebaseio.com/' | |
}) | |
q = Produto.select(Produto.cdchamada, | |
Produto.nmproduto, | |
Produto.stativo).where(Produto.cdchamada.in_(['000003', '000005','000012'])) | |
''' | |
# Inserindo dados. | |
ref = db.reference('/') | |
ref.set({ | |
'Employee': { | |
'Cliente 1': { | |
'name': 'Elias Coutinho', | |
'age': 47, | |
'email': '[email protected]', | |
}, | |
'Cliente 2': { | |
'name': 'Maria Dila', | |
'age': 45, | |
'email': '[email protected]', | |
}, | |
} | |
}) | |
''' | |
produto = [] | |
# Adicionando os dicts do peewee em uma tabela do Firebase. | |
for row in q.dicts(): | |
produto.append(row) | |
#print(row) | |
print(json.dumps(produto, indent=4)) | |
produtos = {'Produtos': produto} | |
#print(json.dumps(produtos, indent=4)) | |
print('***** JSON EXPORTADO *****') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment