1
Good afternoon guys, I have a question and I wanted to ask for your help. I wanted to know how to make a Dataframe in python that stores the data of an sql view and also know how the syntax would look, thanks.
Note: I already made the connection to the database.
Here I make the connection to the database, then I wanted to play my view within a data frame.
import pyodbc
import pandas as pd
#Conexão com Sql Server
connection = pyodbc.connect("DSN=SQLServer")
if connection:
print ("Conectado ao SQL!\n")
try:
with connection.cursor() as cursor:
#Utilizando o fetchal para trazer varios registros
sql = "SELECT * FROM dw.dbo.vW_Vendas"
cursor.execute(sql)
tabela = cursor.fetchall()
print(tabela)
finally:
connection.close()
Ola Ytado would be good for your question if you add the code you made up to the moment. If you are talking about
pandas.DataFramemaybe this will help you pandas.read_sql– Icaro Martins
Thanks I’ll take a look, added the code to improve the question
– Nidorus