Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump sqlalchemy from 1.4.52 to 2.0.36; move to sqlalchemy.text for queries #469

Merged
merged 5 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ jobs:
runs-on: ${{ matrix.os }}
env:
OS: ${{ matrix.os }}
# This is needed to avoid a warning from SQLAlchemy
# https://sqlalche.me/e/b8d9
# We can remove this once we upgrade to SQLAlchemy >= 2.0
SQLALCHEMY_SILENCE_UBER_WARNING: "1"
if: github.event_name != 'schedule'
steps:
- name: Checkout repo
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions pycytominer/cyto_utils/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
output,
provide_linking_cols_feature_name_update,
)
from sqlalchemy import create_engine
from sqlalchemy import create_engine, text

default_compartments = get_default_compartments()
default_linking_cols = get_default_linking_cols()
Expand Down Expand Up @@ -420,12 +420,12 @@ def get_subsample(self, df=None, compartment="cells", rename_col=True):

def count_sql_table_rows(self, table):
"""Count total number of rows for a table."""
(num_rows,) = next(self.conn.execute(f"SELECT COUNT(*) FROM {table}"))
(num_rows,) = next(self.conn.execute(text(f"SELECT COUNT(*) FROM {table}")))
return num_rows

def get_sql_table_col_names(self, table):
"""Get column names from the database."""
ptr = self.conn.execute(f"SELECT * FROM {table} LIMIT 1").cursor
ptr = self.conn.execute(text(f"SELECT * FROM {table} LIMIT 1")).cursor
col_names = [obj[0] for obj in ptr.description]

return col_names
Expand Down Expand Up @@ -476,8 +476,7 @@ def load_compartment(self, compartment):

# Query database for selected columns of chosen compartment
columns = ", ".join(meta_cols + feat_cols)
query = f"select {columns} from {compartment}"
query_result = self.conn.execute(query)
query_result = self.conn.execute(text(f"select {columns} from {compartment}"))

# Load data row by row for both meta information and features
for i, row in enumerate(query_result):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ numpy = ">=1.16.5"
scipy = ">=1.5"
pandas = ">=1.2.0"
scikit-learn = ">=0.21.2"
sqlalchemy = ">=1.3.6, <2"
sqlalchemy = ">=1.3.6,<3"
pyarrow = ">=8.0.0"

# Extra dependencies for cell_locations
Expand Down