Using Python 3.6 and SQL Server I have coded the following to connect to a SQL s
ID: 3600226 • Letter: U
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 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:UsersNathanDesktopMIS 5400UNRATE.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()
Explanation / Answer
ANSWER::
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*" %>
<%
Connection connection = null;
try {
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/myproject","root","root");
String sql="";
}
catch(Exception e)
{
System.out.println(e);
}
%>
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.