Question: Using Python 3.6 and SQL Server I have coded the following to connect to a SQL server and add data from a csv file I

Using Python 3.6 and SQL Server I have coded the following to connect to a SQL server and add data from a csv file I downloaded. I created a table and added the data.(I think) How would I query the data by the top 50 rows? And how would I query the data by the highest years, again like 50 rows? import pyodbc connection_string = 'DRIVER={XXX XXX};SERVER=XX.XX.XX.XXX;DATABASE=MIS5400;UID=mis5400;PWD=Mi$5400' conn = pyodbc.connect(connection_string,autocommit=True) curs = conn.cursor() curs.execute( '''  create table Unemployment_Rate_Mecham(  ID int primary key clustered identity(1,1)  ,ObservationDate datetime  ,CPIAUCSL float  )   '''  ) import csv insert_query = 'insert into Unemployment_Rate_Mecham (ObservationDate, CPIAUCSL) values (?,?)' with open(r'C:\Users\Nathan\Desktop\MIS 5400\UNRATE.csv', 'r',encoding='utf8') as cpi_file: cpi = csv.reader(cpi_file) curs.executemany(insert_query, cpi) conn.commit() conn.close() conn = pyodbc.connect(connection_string,autocommit=True) curs = conn.cursor() 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!