sqlacodegen icon indicating copy to clipboard operation
sqlacodegen copied to clipboard

MSSQL - Connection string parameters causing error

Open ebner87 opened this issue 3 years ago • 1 comments

Hi,

When using MSSQL and passing parameters through its connections string (for example TrustServerCertificate, driver, etc), the package responds saying that the parameter that comes after the "&" is not recognized as a command.

I have made an workaround on my local version to fix this, but maybe there's a better way to take care of it. Below are the changes:

Current cli.py file on lines from 38 to 40

    
    # Use reflection to fill in the metadata
    engine = create_engine(args.url)

Changes on those lines:

    conn_str = args.url
    if 'mssql' in conn_str:
        conn_str = conn_str + '&TrustServerCertificate=yes'

    # Use reflection to fill in the metadata
    engine = create_engine(conn_str)

ebner87 avatar Dec 23 '22 15:12 ebner87

What did you try on the command line? Did you quote the parameters correctly?

agronholm avatar Dec 23 '22 20:12 agronholm