Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No value for argument 'dml' in method call

I am attempting to set up a database which will store story information based on an id number. For now I am working on getting said information into the tables. I am learning python and sql as I go, so bear with me here.

Pylint tells me that there is the following error in reference to title.insert() and I just cannot figure out based on the docs what I am missing here:

No value for argument 'dml' in method call

from ao3 import AO3
api = AO3()
work = api.work(id='1234')

from sqlalchemy import create_engine
engine = create_engine('sqlite:///ficrec.db', echo=True)

from sqlalchemy import Table, Column, Integer, String, MetaData
metadata = MetaData()

title = Table('title', metadata,
    Column('id', Integer, primary_key=True),
    Column('title', String(256))
)
author = Table('author', metadata,
    Column('id', Integer, primary_key=True),
    Column('author', String(128))
)
ins = title.insert().values(id=work.id, title=work.title)
like image 991
Reanna Avatar asked Jan 03 '19 22:01

Reanna


1 Answers

I got the same problem. Basically, insert() requires a param which is dml. Since it is not provided, pylint complains error like below.

[pylint] No value for argument 'dml' in method call [E1120]

It doesn't look there is functionality issue by not providing dml. Based on briefly checking source code, the dml is generated by decorator

@util.dependencies("sqlalchemy.sql.dml")
def insert(self, dml, values=None, inline=False, **kwargs):
    """Generate an :func:`.insert` construct against this
    :class:`.TableClause`.

    E.g.::

        table.insert().values(name='foo')

    See :func:`.insert` for argument and usage information.

    """

    return dml.Insert(self, values=values, inline=inline, **kwargs)

In order to move on, in my case, I passed None value to insert() for NOW. I'm not sure if it is good idea or not. Hopefully, SQLAlchmey community handles this issue.

For you, try this way.

ins = title.insert(None).values(id=work.id, title=work.title)

like image 98
Gatsby Lee Avatar answered Nov 20 '22 08:11

Gatsby Lee