sqlalchemy.exc.OperationalError:(pyodbc.OperationalError)-登录超时已过期

时间:2019-11-21 19:49:20

标签: python sqlalchemy pyodbc

我正在尝试使用pyodbc和SQLAlchemy连接到SQL Server,但是我不断收到以下错误-

sqlalchemy.exc.OperationalError:(pyodbc.OperationalError)('HYT00','[HYT00] [Microsoft] [ODBC SQL Server驱动程序]登录超时已过期(0)(SQLDriverConnect); [HYT00] [Microsoft] [ODBC SQL Server驱动程序]无效的连接字符串属性(0)')

这是我的代码-


    DATABASE = 'fake_database'
    USERNAME = 'fake_username'
    PASSWORD = 'fake_password'
    SERVER = 'fake_server'

    conn = urllib.parse.quote_plus('DRIVER={SQL Server};SERVER=%s;\
                               DATABASE=%s;UID=%s;PWD=%s;CHARSET=UTF8' \
                                % (SERVER, DATABASE, USERNAME, PASSWORD))
    engine1 = sqlalchemy.create_engine('mssql+pyodbc:///?odbc_connect={}'.format(conn))

    analyst_company = """
    select T1. fake_command
    """
    analyst_country = """select * from fake_command2"""
    analyst_company_df = pd.read_sql(analyst_company, engine1)
    analyst_country_df = pd.read_sql(analyst_country, engine1)

0 个答案:

没有答案