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

Check compatibility with latest version of sqlalchemy #13

Open
stefancoe opened this issue May 7, 2024 · 1 comment
Open

Check compatibility with latest version of sqlalchemy #13

stefancoe opened this issue May 7, 2024 · 1 comment

Comments

@stefancoe
Copy link

Latest version is 2.0.

This code failed using the current version. I replaced it with this:

import pandas as pd
import geopandas as gpd
from shapely import wkt
from pymssql import connect
from sqlalchemy import create_engine, text
import urllib
import pyodbc
import toml


def load_elmer_table(table_name, sql=None):
    conn_string = "DRIVER={ODBC Driver 17 for SQL Server}; SERVER=AWS-PROD-SQL\Sockeye; DATABASE=Elmer; trusted_connection=yes"
    params = urllib.parse.quote_plus(conn_string)
    engine = create_engine("mssql+pyodbc:///?odbc_connect=%s" % params)

    if sql is None:
        sql = "SELECT * FROM " + table_name

    df = pd.DataFrame(engine.connect().execute(text(sql)))

    return df
christopeak added a commit that referenced this issue May 9, 2024
use urllib.parse() in sqlalchemy engine creation.  Fixes #13
@christopeak christopeak reopened this May 9, 2024
@christopeak
Copy link
Contributor

@stefancoe This seems to be working for me. I could not replicate the problem you were having, even in a new environment with the most recent sqlalchemy, so I will need you to confirm it works for you. I implemented the change you suggested in your load_elmer_table snippet above. Let me know?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants