On Fri, Dec 28, 2018 at 4:57 AM Kamil Rozmus <[email protected]> wrote:
>
> I want to add a record into the database, but the compiler returns me the 
> error. I searched similar problems and I couldn't find the solution.
>
>     class Packages(Base):
>        __tablename__ = "packages"
>
>        id_package = Column(Integer, primary_key=True)
>        name_of_package = Column(String)
>        price = Column(Integer)
>
>        def __init__(self, name_of_package, price):
>           self.name_of_package = name_of_package
>           self.price = price
>
> And then I am inserting the record.
>
>     package = Packages('Economy', 5000)
>     session.add(package)
>
> I've missed `id_package`, because it is Primary Key. I receive the following 
> error.
>
> > Exception has occurred: TypeError
> > id() takes exactly one argument (0 given)
> > File "C:\***\&lt;string&gt;", line 2, in __ init __
> File "C:\***\module.py", line 135, in <module>
> package = Packages('Economy', 5000)
>
> Line 2 = `from sqlalchemy import Column, Date, Integer, String`
>
> Any ideas?

your example does not seem to illustrate it but it seems likely
somewhere you are using the symbol "id" but it is in fact the Python
built-in id() function which expects an argument.

>
>
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
> ---
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to