Jul-21-2020, 10:14 AM
good day, i got an assignment but i don't understand parts of it, because I never makes a DB like this in java.
I created the DB and gave the columns a name, and now I get did as an assignment.
Question 1
what do they want me to do specifically?
Question 2
I created the DB and gave the columns a name, and now I get did as an assignment.
Question 1
def insert_into_database(cursor, data): """ Load all selected data from the CSV to the database. """ ### FILL IN - START ### # Add your column names as (col1, col2, ..., col_n) column_names = "(col1,col2 )" # Add empty values as (?, ?, ..., ?) with the same amount of ? as column names. values = "(?, ?, )" # Fill this list with tuples of values from the columns. # Each tuple represents one row. # (value1, value2, ..., value_n) # Example: ("Avatar", "James Cameron", 2009-12-17, 162, 237000000, 760507625.0) insert_into_db = [] ### FILL IN - END ### cursor.executemany("""INSERT INTO movies {} VALUES {};""".format(column_names, values), insert_into_db)what I understand I have to enter the column names again only shortened because you can only use 166 charter in that line, and the next step is to add the value
what do they want me to do specifically?
Question 2
if __name__ == "__main__": data = None with open(DATA_PATH) as data_file: data = csv.reader(data_file, delimiter=";") connection = sqlite3.connect(DATABASE_PATH) cursor = connection.cursor() create_database(cursor) insert_into_database(cursor, data) ### FILL IN - START ### # Create two functions similar to create_database and insert_into_database. # Call those functions here. # This time, you will create an actors table and fill it with actor data from actor_dataset.csv # Note that this will just be added to the existing database movies.db ### FILL IN - END ### connection.commit() connection.close()if I understand they want me to repeat the previous steps to create the other two database tables?