FAQ
I get the following error:

File "<stdin>", line 1, in ?
File "/Users/fulvio/plone/seiu_new/buildout/eggs/z3c.saconfig-0.11-
py2.4.egg/z3c/saconfig/utility.py", line 164, in __call__
_ENGINES[self._key] = engine = sqlalchemy.create_engine(
File "/Users/fulvio/plone/seiu_new/buildout/eggs/SQLAlchemy-0.6.3-
py2.4.egg/sqlalchemy/engine/__init__.py", line 244, in create_engine
return strategy.create(*args, **kwargs)
TypeError: create() takes exactly 2 non-keyword arguments (150 given)

Basically, args and kwargs come as the return values from my
overridden function configuration():

args, kw = self.configuration()
_ENGINES[self._key] = engine =
sqlalchemy.create_engine(
*args, **kw)


This is what I'm returning from configuration():

args = (connection_string)
kwargs = {'echo' : True, 'encoding' : 'cp1252'}
return args, kwargs

In other words, args is a list containing just one string. It seems
to me that create_engine is interpreting that as a list of 150
characters.

Any suggestions, on what I'm doing wrong?

Thanks!
Fulvio

Search Discussions

  • James Mills at Jul 22, 2010 at 6:53 am

    On Thu, Jul 22, 2010 at 4:26 PM, fulv wrote:
    ?args = (connection_string)
    Replace this with:

    args = (connection_string,)

    NOTE: The trailing , (comma) indicating that this _is_ a tuple.

    cheers
    James

    --
    -- James Mills
    --
    -- "Problems are solved by method"
  • Ben Finney at Jul 22, 2010 at 6:56 am

    fulv <fulviocasali at gmail.com> writes:

    return strategy.create(*args, **kwargs)
    TypeError: create() takes exactly 2 non-keyword arguments (150 given)

    Basically, args and kwargs come as the return values from my
    overridden function configuration():

    args, kw = self.configuration()
    _ENGINES[self._key] = engine =
    sqlalchemy.create_engine(
    *args, **kw)
    (As a side note: Please use a mail client that won't wrap your lines
    incorrectly like the above. That might mean not using Google Mail.)
    This is what I'm returning from configuration():

    args = (connection_string)
    kwargs = {'echo' : True, 'encoding' : 'cp1252'}
    return args, kwargs

    In other words, args is a list containing just one string.
    No, it isn't. The syntax you've used merely puts parentheses around the
    object ?connection_string?; parentheses don't make a list. So, when you
    use the argument unpacking syntax, the string gets unpacked into its
    component characters, as you noticed.

    You might have meant ?a tuple containing just one string?. But
    parentheses don't make a tuple either.

    To make a tuple, use commas. You may put parentheses around the tuple to
    distinguish it from surrounding syntax, and because commas are used in
    various other places, sometimes you need to. But never forget that it's
    the commas that make the tuple, not the parentheses.

    args = (connection_string,)
    kwargs = {'echo': True, 'encoding': 'cp1252'}
    return args, kwargs

    I hope that helps.

    --
    \ ?It is far better to grasp the universe as it really is than to |
    `\ persist in delusion, however satisfying and reassuring.? ?Carl |
    _o__) Sagan |
    Ben Finney
  • Fulv at Jul 22, 2010 at 4:01 pm
    Thank you all! Really appreciate the quick help!

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJul 22, '10 at 6:26a
activeJul 22, '10 at 4:01p
posts4
users3
websitepython.org

3 users in discussion

Fulv: 2 posts James Mills: 1 post Ben Finney: 1 post

People

Translate

site design / logo © 2022 Grokbase