You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This lecture has codeblocks for sqlite3 code instead of having an interactive activecode like other lectures. This is because Runestone does not support the sqlite3 library from python. Bython does not support it either.
Because of these reasons it is needed to find a way to use sqlite3 inside the book or replan this lecture in a way to teach with SQL.
By far there has been 3 attemps of refactoring the lecture, here they are order by closest to the solution:
Using the activecode SQL languge from Runestone: SQL activecode approach #185
Some configuration to use this SQL tool from Runestone must be done, because when you try to access the file surf.db, a CORS error shows up in console and nothing is shown. There might be something related with the book not being served by Runestone because in this error it tries to access to the db from an URL in runestone site: /runestone/books/published/PyZombis/_static/sql-wasm.wasm asuming that the book is published.
Using sql.js library from javascript: Refactor lecture TWP42: Bases de datos (sql.js approach) #184
This other option loads the database using the .. raw:html instruction from runestone.
This is the best attempt since you need to find a way to access to the global javascript variable db from the brython activecode block. Enter this PR for more detail, but if you call db in browser console you can see the database.
cursor.execute("select * from surfers where age > 25")
linhas = cursor.fetchall()
for linha in linhas:
print("id :",linha['id'])
print("Nombre :",linha['name'])
print("Pais :",linha['country'])
print("Media :",linha['average'])
print("Estilo :",linha['board'])
print("Edad :",linha['age'])
print()
had to change to:
if(getattr(v, "edad") >=25):
for key in ["nombre", "pais", "media", "estilo", "edad"]:
print(f"{key}: {getattr(v, key)}")
getattr(res, "continue")()
It is not a friendly syntax for new students that are learning this for the first time.
The text was updated successfully, but these errors were encountered:
This lecture has codeblocks for sqlite3 code instead of having an interactive activecode like other lectures. This is because Runestone does not support the sqlite3 library from python. Bython does not support it either.
Because of these reasons it is needed to find a way to use sqlite3 inside the book or replan this lecture in a way to teach with SQL.
By far there has been 3 attemps of refactoring the lecture, here they are order by closest to the solution:
Using the activecode SQL languge from Runestone: SQL activecode approach #185
Some configuration to use this SQL tool from Runestone must be done, because when you try to access the file
surf.db
, a CORS error shows up in console and nothing is shown. There might be something related with the book not being served by Runestone because in this error it tries to access to the db from an URL in runestone site:/runestone/books/published/PyZombis/_static/sql-wasm.wasm
asuming that the book is published.Using sql.js library from javascript: Refactor lecture TWP42: Bases de datos (sql.js approach) #184
This other option loads the database using the
.. raw:html
instruction from runestone.This is the best attempt since you need to find a way to access to the global javascript variable
db
from the brython activecode block. Enter this PR for more detail, but if you call db in browser console you can see the database.With indexedDB: Refactor Lecture TWP42: Bases de datos (indexedDB approach) #171
This aproach works, but the syntax changes a lot from the original lecture where
sqlite3
was used.For example:
had to change to:
It is not a friendly syntax for new students that are learning this for the first time.
The text was updated successfully, but these errors were encountered: