Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

2
Databases and Tables
Post Body

Hi all, I am a newbie Python user, and I'm dumb as hell. I can't figure out how to figure out the assignment, which I will post here:

  1. Read in Student_Grade_Prediction2.csv as Students_df and create a database called Students.
    Remember that you also need to create a cursor to execute the commands below.

    1. Select all the students who scored less than or equal to 12 on the first exam (G1) ordered in
      descending order by the first exam scores.

As you can see, I am supposed to read in a csv file, create a database, and then a table with a cursor? I don't know really, this is where I get lost. Here is my code:

import sqlite3

con = sqlite3.connect('Students_df')

cursor = conn.cursor()

import pandas as pd

Students = pd.read_csv(

'Student_Grade_Prediction2.csv')

Students.to_sql("Student_records", con, if_exists = "replace")

cursor.execute("CREATE TABLE IF NOT EXISTS students (ID INT PRIMARY KEY, school TEXT, sex TEXT, age INT, address TEXT, famsize TEXT, Pstatus TEXT, Medu INT, Fedu INT, Mjob TEXT, Fjob TEXT, reason TEXT, guardian TEXT, traveltime INT, studytime INT, failures INT, schoolsup TEXT, famsup TEXT, paid TEXT, activities TEXT, nursery TEXT, higher TEXT, internet TEXT, romantic TEXT, famrel INT, freetime INT, goout INT, Dalc INT, Walc INT, health INT, absences INT, G1 INT, G2 INT, G3 INT;))"

I'm getting an "unexpected EOF while parsing" error

Sorry if this is against rules, I just really need help. Thanks in advance

Author
Account Strength
80%
Account Age
6 years
Verified Email
Yes
Verified Flair
No
Total Karma
22
Link Karma
4
Comment Karma
18
Profile updated: 1 week ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago