I forget post the error message:
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.
El martes, 22 de marzo de 2016, 6:05:44 (UTC+1), Ricardo Champa escribió:
>
> 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()
>
>
--
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.