Skip to content

Commit

Permalink
- Added file to move data from csv to database
Browse files Browse the repository at this point in the history
- Added file to see if data is being added to database
- important_functions.py will be used in future for
a web interface.
- Deleted pucit_result.csv
  • Loading branch information
iPythonezta committed Jun 26, 2024
1 parent dce3a58 commit 7651b93
Show file tree
Hide file tree
Showing 9 changed files with 35,676 additions and 14,254 deletions.
27 changes: 27 additions & 0 deletions csv-to-database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pandas as pd
import sqlite3

csv_file = 'results/pucit_result.csv'
df = pd.read_csv(csv_file)
df.drop_duplicates(subset=['Roll Number'], inplace=True)

conn = sqlite3.connect('results-database/students.sqlite3')
cursor = conn.cursor()

create_table_query = '''
CREATE TABLE IF NOT EXISTS students_data (
roll_number INTEGER PRIMARY KEY,
category_of_admission_test TEXT NOT NULL,
marks_obtained INTEGER NOT NULL
)
'''
cursor.execute(create_table_query)

for index, row in df.iterrows():
cursor.execute('''
INSERT INTO students_data (roll_number, category_of_admission_test, marks_obtained)
VALUES (?, ?, ?)
''', (row['Roll Number'], row['Name of Category of Admission Test'], row['Marks Obtained']))

conn.commit()
conn.close()
Loading

0 comments on commit 7651b93

Please sign in to comment.