I've no idea what the problem is, but it seems strange that you are passing
"id_project" as the second parameter to Tag(), when the __init__ function
appears to be expecting a Proyecto instance. Is that deliberate, or a
mistake?

Simon

On Tue, Mar 22, 2016 at 5:09 AM, Ricardo Champa <[email protected]>
wrote:

> I'm getting an error after perform an insert statement.
>
> class Tag(db.Model):
>     __tablename__ = "tags"
>     guid_tag      = db.Column(db.BINARY(16), primary_key=True)
>     id_project  = db.Column(db.Integer,db.ForeignKey("projects.id_project"))
>     project     = db.relationship(Proyecto, backref=db.backref('list_tags', 
> lazy='dynamic'))
>     type        = db.Column(db.Integer) 
> #(0,hub);(1,cable);(2,pipe);(3,electrical_pipes)
>     created_at  = db.Column(db.DateTime)
>     updated_at  = db.Column(db.DateTime)
>
>     def __init__(self,guid_tag,project,type,created_at):
>         self.guid_tag = guid_tag
>         self.project = project
>         self.type = type
>         self.created_at = created_at
>         self.updated_at = created_at
>
> Insert statement
>
> guid_tag    = func.UNHEX(args['guid_tag'])
> nuevo_tag = Tag(guid_tag,id_project,type,creado_en)
> db.session.add(nuevo_tag)
> db.session.commit()
>
> The message error
>
> File
> "/Users/Ricardo/PycharmProjects/virtual_rfwire/lib/python3.3/site-packages/sqlalchemy/orm/loading.py",
> line 647, in load_scalar_attributes "contain a full primary key." %
> state_str(state)) sqlalchemy.exc.InvalidRequestError: Instance cannot be
> refreshed - it's not persistent and does not contain a full primary key.
>
> --
> 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.
>

-- 
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