Created
April 24, 2019 12:17
-
-
Save endersonmenezes/3955970080e54743522158d440ae790b to your computer and use it in GitHub Desktop.
Django - Cursor MongoDB to Pandas DataFrame
This file contains 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
import pymongo | |
import pandas as pd | |
from pymongo import MongoClient | |
def test_view(request): | |
client = MongoClient('Mongo URI') # Conexão ao Banco | |
db = client['database_name'] # Seleção de Banco de Dados | |
test = db.test # Seleção da Coleção de Dados | |
test = pd.DataFrame(list(test.find())) #Consulta tudo na Coleção -> Lista (python) -> DataFrame (pandas) | |
print(test) # Exibe a 'tabela' para teste :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment