Skip to content

Commit

Permalink
Upgrade to sqlalchemy>=2 (#1788)
Browse files Browse the repository at this point in the history
* Upgrade to sqlalchemy>=2

* Update alembic migration files for sqlalchemy 2
  • Loading branch information
tuncbkose committed Jun 16, 2023
1 parent 97160b4 commit 83a0429
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 63 deletions.
8 changes: 4 additions & 4 deletions nbgrader/alembic/versions/167914646830_added_task_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ def upgrade():
)

connection = op.get_bind()
results = connection.execute(sa.select([
results = connection.execute(sa.select(
old_grade_table.c.name,
old_grade_table.c.id,
old_grade_table.c.cell_type,
old_grade_table.c.notebook_id,
old_grade_table.c.max_score
])).fetchall()
)).fetchall()

# copy info to the base_cell table
base_grade_cells = [
Expand All @@ -109,11 +109,11 @@ def upgrade():
op.bulk_insert(new_grade_table, grade_cells)

# now transfer the solution cells...
results = connection.execute(sa.select([
results = connection.execute(sa.select(
old_solution_table.c.name,
old_solution_table.c.id,
old_solution_table.c.notebook_id,
])).fetchall()
)).fetchall()

# copy info to the base_cell table
base_solution_cells = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ def upgrade():

# If the course table is empty, create a default course
connection = op.get_bind()
res = connection.execute("select id from course")
res = connection.execute(sa.text("select id from course"))
results = res.fetchall()
default_course = "default_course"

if len(results) == 0:
connection.execute(
"INSERT INTO course (id) VALUES ('{}')".format(default_course))
sa.text("INSERT INTO course (id) VALUES ('{}')".format(default_course))
)

with op.batch_alter_table("assignment") as batch_op:

Expand Down
Loading

0 comments on commit 83a0429

Please sign in to comment.