Need help learning Julia (tutorial example doesn't work for SQLite.Query

Good afternoon. I’m trying to learn Julia and found a long tutorial (over 4 hours). I’ve been tracking along pretty well until I hit the database section using the SQLite package. I’ve created the DB (a very simple one entry movies database with only a couple of fields) and have been able to complete the tutorial with only minor issues until I reached this stage. We are using the SQLite package and this is the command I am trying to execute and the error response I receive:

Command:

using Pkg
Pkg.add("SQLite")
using SQLite

db = SQLite.DB("Movies")
SQLite.execute(db,"CREATE TABLE IF NOT EXISTS movies(movie_id REAL, movie_name  TEXT, location TEXT")
SQLite.tables(db)
SQLite.execute(db,"INSERT INTO Movies (movie_id,movie_name,location) VALUES(1,'Avengers','USA')")
SQLite.Query("SELECT * FROM movies")

The error I receive is:

using Pkg
Pkg.add("SQLite")
using SQLite

db = SQLite.DB("Movies")
SQLite.execute(db,"CREATE TABLE IF NOT EXISTS movies(movie_id REAL, movie_name  TEXT, location TEXT")
SQLite.tables(db)
SQLite.execute(db,"INSERT INTO Movies (movie_id,movie_name,location) VALUES(1,'Avengers','USA')")
SQLite.Query("SELECT * FROM movies")

I really don’t know what this means from a diagnostic standpoint, but I’m wondering if something has changed with the package since the tutorial was posted or because of the version difference in Julia itself. Tutorial was from October 2019 and was using Julia 1.2.0. I’m on 1.6.1.

You posted the code twice rather than including the error. Also, could you please link the tutorial that you are using.

I would be interested in the link also

Sorry for the wrong posting. The tutorial I’m using is Julia Tutorial \ Julia Data Science Basic Full Course [Complet Tutorial] for Beginners [2019]

I actually found the answer after a bit more Googling. It appears the tutorial is wrong. The correct way to do this is to use something like this:

# To load a specific table (movies table from Movies.db)
q = "SELECT * FROM movies"
data = SQLite.DBInterface.execute(db,q)

DataFrames.DataFrame(data)

This produces the correct output.

Thanks for your quick responses, but I can close the .question now as I found the answer. I’ve found another couple things in the tutorial that are wrong, but for the most part, it’s been pretty spot on.

1 Like