I am following along in the “Julia Programming Projects” book (by Adrain Salceanu). I have Julie 1.4.0 and have had to use some package versions that are obviously more recent than his (I tried using the packages/manifests available with the book but there were too many conflicts especially with IJulia). In Chapter four we connect to a MySQL database. I have had to change the code for it to work with the most recent version and use “DBInterface” to connect and execute. So far so good. I have a data-table and some data stored in it. My problem comes when I query the table. I can’t do it as per the book and all examples I can find and must use our new friend “DBInterface” as follows:
articles = Article # Article is a struct matching the columns in the db table
sql = “SELECT * FROM articles WHERE url = ‘$url’”
result = DBInterface.execute(CONN, sql)
This works but the next line in the book’s code does not:
isempty(result.url) && return articles
The line above results in the error: “ERROR: LoadError: type TextCursor has no field url”. I guess the old MySQL.query method was a convenience method that auto-converted the rows retrieved by a cursor into an array or something. What I can’t find (or don’t understand) is how to handle the TextCursor object because it has no methods according to the documentation in Julia, so I can’t figure out how to iterate with it, or get all the results - it might well be empty too (no rows in DB).
So, I’m feeling a bit stupid because I can do this sort of thing in Python with Postgresql but am completely failing with Julia and MySQL. Can somebody walk me through this please?