wrong keyword argument to create_engine cached acrossed function calls

Issue #182 resolved
Former user created an issue

If create_engine is called with a misspelled keyword argument, the second call to the function repeats the same error, even if the keyword argument is correctly fixed in the second call.

In the following example, 'echo=True' is misspelled as 'eche=True', and after the first error, there is no way to correct the error and get the engine created:

  >>> from sqlalchemy import *
  >>> _engine=create_engine('postgres://database=test&host=localhost&user=postgres&password=asdf', eche=True)
  Traceback (most recent call last):
    File "<input>", line 1, in ?
    File "build\bdist.win32\egg\sqlalchemy\engine.py", line 80, in create_engine
    File "build\bdist.win32\egg\sqlalchemy\databases\postgres.py", line 172, in engine
    File "build\bdist.win32\egg\sqlalchemy\databases\postgres.py", line 208, in __init__
    File "build\bdist.win32\egg\sqlalchemy\engine.py", line 241, in __init__
    File "build\bdist.win32\egg\sqlalchemy\pool.py", line 273, in get_pool
    File "build\bdist.win32\egg\sqlalchemy\pool.py", line 191, in __init__
  TypeError: __init__() got an unexpected keyword argument 'eche'
  >>> _engine=create_engine('postgres://database=test&host=localhost&user=postgres&password=asdf', echo=True)
  Exception exceptions.AttributeError: <exceptions.AttributeError instance at 0x01C3C9E0> in <bound method QueuePool.__del__ of <sqlalchemy.pool.QueuePool object at 0x01C1A410>> ignored
  Traceback (most recent call last):
    File "<input>", line 1, in ?
    File "build\bdist.win32\egg\sqlalchemy\engine.py", line 80, in create_engine
    File "build\bdist.win32\egg\sqlalchemy\databases\postgres.py", line 172, in engine
    File "build\bdist.win32\egg\sqlalchemy\databases\postgres.py", line 208, in __init__
    File "build\bdist.win32\egg\sqlalchemy\engine.py", line 241, in __init__
    File "build\bdist.win32\egg\sqlalchemy\pool.py", line 273, in get_pool
    File "build\bdist.win32\egg\sqlalchemy\pool.py", line 191, in __init__
  TypeError: __init__() got an unexpected keyword argument 'eche'
  >>> _engine
  Exception exceptions.AttributeError: <exceptions.AttributeError instance at 0x01C34760> in <bound method QueuePool.__del__ of <sqlalchemy.pool.QueuePool object at 0x01C3A230>> ignored
  Traceback (most recent call last):
    File "<input>", line 1, in ?
  NameError: name '_engine' is not defined

Comments (4)

  1. Mike Bayer repo owner

    yeah this is actually something thats only in SA 0.1, its because the SQLEngine is using the pool.manage function when it starts up, in an attempt to share its connection pool with other parts of the calling application that might be also using manage by itself, which then registers those init arguments in a module-level dictionary inside the pool module. but that was a silly idea that isnt present in SA 0.2, when you make an engine in 0.2 it just makes itself a pool internally...if you want a pooled connection without any other SA stuff, thats still your pool. so this problem is essentially fixed by 0.2.

  2. Log in to comment