Search code examples
pythonpython-3.xdatabasesqliteklepto

How to set a table name using klepto sqltable_archive in Python 3?


Based on the klepto docs

Using:

klepto.archives.sqltable_archive('sqlite:///foo.db', cached=False)

Successfully creates a database with the default table name of memo

However, when table is also included:

klepto.archives.sqltable_archive('sqlite:///foo.db', table='bar', cached=False)

The following error occurs:

  line 159, in __new__
    archive = _sqltable_archive(db, table, **kwds)
TypeError: __init__() got multiple values for argument 'table'

pointing to line 159 in klepto.archives

Any help is much appreciated!


Solution

  • I'm the klepto author. Sorry the docs are not clear there. If you look at the line above (i.e. line 158), you'll see that the table name is set with the keyword name... which then gets split into the db name and the table name. I guess I could throw a better error when table is given as a keyword argument.