it's ok, it's saving but what is strange is that my query doesn't find this
records:
this is my sql :
sql = 'SELECT ss.id, ss.name, ss.image_metadata FROM (SELECT image.id,
image.image_metadata, image.name,
json_array_elements(image.uri_reference)::text as uri_ref FROM image) ss
WHERE ss.uri_ref = :uri ORDER BY ss.id LIMIT 5'
result = self.session.execute(text(sql).params(uri=uri))
return result
Le mer. 27 mars 2019 à 16:04, Scheck David a écrit :
> Hi everyone,
>
> I try to update an attribute but it appears that it doesn't save. Would
> you know why ? it's very strange because the print is good. but when I
> query again this uri_reference it finds Nonetype.
>
> here is the command :
>
> ```
>
> @contextlib.contextmanager
> def db_session(settings):
> engine = engine_from_config(settings, 'sqlalchemy.')
> session_maker = sessionmaker(bind=engine)
> session = session_maker()
> try:
> yield session
> session.commit()
> except Exception:
> session.rollback()
> finally:
> session.close()
>
>
> def process(settings):
> """
> Command to migrate urls to a single JSON field for performance issues
> """
> with db_session(settings) as session:
> print ("")
> print ("SELECTING ALL IMAGES")
> print ("")
> for image in session.query(Image).limit(40).all():
> urls = _list_uri_references_for_data(image.image_metadata)
> urls.append(image.state.actor_uri)
> image.uri_reference = urls
> print ("{}: SAVING -> {}".format(image.name,
> image.uri_reference))
> print ("")
> print ("CLOSING SCRIPT")
> print ("")
> ```
>
> Thanks in advance.
>
> --
> 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 a topic in the
> Google Groups "sqlalchemy" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/sqlalchemy/F0WBuRrxa4Q/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
>
--
With kindest regards,
*David SCHECK*
PRESIDENT/DEVELOPER
[image: Signature Logo Sphax Bleu-01.png]
Phone: +32 4 87 86 70 12
Visit our website ! https://www.sphax.org
--
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.