Thank you. Could you please also give some hint on a case where we must set
this attribute to `False`?
On Wed, May 26, 2021 at 5:54 AM Mike Bayer wrote:
>
>
> On Wed, May 26, 2021, at 3:07 AM, niuji...@gmail.com wrote:
>
> I have consistently receiving the warning:
> will not produce a cache
Thanks. One thing to clarify, I noticed that here you used `case` without
using in a context of `select`. Is this considered a shorthand within
sqlalchemy?
On Fri, Dec 11, 2020 at 2:16 AM Simon King wrote:
> You can do it, but you need to use an SQL conditional rather than a
> python one. In
Thanks very much for the informative reply Mike!
On Sun, Aug 6, 2017 at 9:38 PM, Mike Bayer <clas...@zzzcomputing.com> wrote:
>
>
> On Aug 6, 2017 8:11 PM, "Jinghui Niu" <niujing...@gmail.com> wrote:
>
> When reading the official SQLAlchemy docum
When reading the official SQLAlchemy documentation, I found the example
below:
### this is the **wrong way to do it** ###
class ThingOne(object):
def go(self):
session = Session()
try:
session.query(FooBar).update({"x": 5})
session.commit()
I'm using Sqlite as backend, which doesn't use any connection pools. In my
case, I don't know if there is any negative consequences to just let Python
garbage collect each Session instance after use? Especially under a
multi-threading context. Could someone point out any risks not closing them
That's it! Thanks!
On Saturday, August 5, 2017 at 3:15:28 PM UTC-7, Jonathan Vanasco wrote:
>
>
> http://docs.sqlalchemy.org/en/latest/orm/session_api.html#sqlalchemy.orm.session.Session.connection
>
>
>
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
But it's not for returning a connection object?
On Aug 5, 2017 1:51 PM, "Ruben Di Battista" <rubendibatti...@gmail.com>
wrote:
> session.bind?
>
> On Saturday, August 5, 2017 at 2:36:53 PM UTC+2, Jinghui Niu wrote:
>>
>> Is there a way to get the curren
Is there a way to get the currently binding Engine or Connection from a
Session object? The backend database is Sqlite. Thanks.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and
Thanks Simon. Your answers always help immensely getting to know SA better.
I now know the overview.
On Tue, Jul 25, 2017 at 1:45 AM, Simon King <si...@simonking.org.uk> wrote:
> On Tue, Jul 25, 2017 at 2:35 AM, Jinghui Niu <niujing...@gmail.com> wrote:
> > I was wonder
I was wondering if there is a way to configure Session.commit() so on each
successful commit, it will return the committed/updated/deleted instance's
class.__name__ + row.id. Is this possible? Thanks.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
Now I see, thanks Mike!
On Jul 20, 2017 6:51 PM, "Mike Bayer" <mike...@zzzcomputing.com> wrote:
> On Thu, Jul 20, 2017 at 8:10 PM, Jinghui Niu <niujing...@gmail.com> wrote:
> > I see. But still I'm struggling to see the real difference between:
> >
I see. But still I'm struggling to see the real difference between:
Node.parent_id = Node.id
vs.
Node.id = Node.parent_id
Aren't we just switching around sides here?
On Thu, Jul 20, 2017 at 4:47 PM, Mike Bayer <mike...@zzzcomputing.com>
wrote:
> On Thu, Jul 20, 2017 at 1:34 PM, Ji
I've been studying sqlalchemy's self referential table. I've read the
documentation many times and still have difficulties understanding the
concept of remote_side. Could someone please draw a diagram or use an
analogy to help explain this concept? I think visualizing is a better way
but
, July 13, 2017 at 4:38:19 PM UTC-7, Jinghui Niu wrote:
>
> I have a web application served by cherrypy (, which is multi-threaded. )
>
> I'm trying to cache a set of rows queried from database using
> `self.search_result_cache` variable on the GUI_Server object. On my
> front-
Hi Mike, I've read the example of dogpile caching. For my case
dogpile.cache seems to be a overkill, could you please provide a thinner
example of using Query.merge_result without involving another library?
Thanks.
On Thu, Jul 13, 2017 at 8:07 PM, Jinghui Niu <niujing...@gmail.com>
hod that I've used in production successfully.
>
>
>
>
>
> On Thu, Jul 13, 2017 at 7:38 PM, Jinghui Niu <niujing...@gmail.com> wrote:
> > I have a web application served by cherrypy (, which is multi-threaded. )
> >
> > I'm trying to cache a set of rows queri
I have a web application served by cherrypy (, which is multi-threaded. )
I'm trying to cache a set of rows queried from database using
`self.search_result_cache` variable on the GUI_Server object. On my
front-end, the web first request `list_entries` to prepare the rows and
stores them on
that leaves just MySQL out.
>
> On 10/16/2016 01:21 PM, Jinghui Niu wrote:
>
>> Thanks Mike.
>>
>> On Sun, Oct 16, 2016 at 7:14 AM, Mike Bayer <mike...@zzzcomputing.com
>> <mailto:mike...@zzzcomputing.com>> wrote:
>>
>>
>>
>> On 10/
Thanks Mike.
On Sun, Oct 16, 2016 at 7:14 AM, Mike Bayer <mike...@zzzcomputing.com>
wrote:
>
>
> On 10/14/2016 06:08 PM, Jinghui Niu wrote:
>
>> I have the following Table model representing a timeline.
>>
>> |
>> classTimeRange(Bas
14, 2016 at 3:08:32 PM UTC-7, Jinghui Niu wrote:
>
> I have the following Table model representing a timeline.
>
> class TimeRange(Base):
>
>
> __tablename__ = "time_line"
>
>
> record_id = Column(Integer, primary_key=True)
> level = Column(Str
I have the following Table model representing a timeline.
class TimeRange(Base):
__tablename__ = "time_line"
record_id = Column(Integer, primary_key=True)
level = Column(String, nullable=False) # e.g. "Point", "Range"
content = Column(String, nullable=False)
t; parameter is now the
> *class*, so self.firstname and self.lastname are SQLAlchemy column
> properties. Since SA implements the "+" operator for those properties,
> the result of the expression is an SQL expression. When you write
> "User.fullname == 'Jinghui
nderstood your comment here?
On Mon, Oct 3, 2016 at 1:40 AM, Jinghui Niu <niujing...@gmail.com> wrote:
> Thank you Simon. Your explanation helps me understand this quite a lot.
> Sometimes the documentation is so terse that only when you fully understand
> the subject then you can
suggest modify my current code? Or maybe you could please point out a link
to where I can explore further on the python to SQL transition? Thank you
so much.
Jinghui
On Mon, Oct 3, 2016 at 1:27 AM, Simon King <si...@simonking.org.uk> wrote:
> On Mon, Oct 3, 2016 at 7:17 AM, Jinghui Niu
I have a ledger table and a corresponding python class. I defined the model
using SQLAlchemy, as follows,
class Ledger(Base):
__tablename__ = 'ledger'
currency_exchange_rate_lookup = {('CNY', 'CAD'): 0.2}
amount = Column(Numeric(10, 2), nullable=False)
currency =
The documentation shows that hybrid_property should used as a decorator,
like:
@hybrid_property
def my_property(self):
pass
What if I wanted to give this hybrid property a name by referring a
variable in runtime? Is this allowed? Thanks.
--
You received this message because you are
For example, I have a Mixin as follow:
class MyNoteMixin:
note = Column(String)
Now I have a subclass that inherit from the above Mixin, but needs two
different columns both are of a note nature. Can I do something like:
class Child(Base, MyNoteMixin as "Description", MyNoteMixin as
DATE(timepoint, ),
> STR_TO_DATE(timepoint, ))
>
> If you're not actually going to filter on these columns, I don't think
> I'd do any of this at all. Instead, I'd use something like a
> TypeDecorator to convert the values when loading from and saving to
> the database.
>
>
my database.
I admit that it's one of my personal preference though:)
On Fri, Sep 16, 2016 at 1:49 AM, Jinghui Niu <niujing...@gmail.com> wrote:
> Thanks for reply.
>
> The reason is simple. I plan in the future to accommodate datetime range
> into that column as well, so sto
aps with a second column to indicate whether or not the
> time part is valid)?
>
> Simon
>
> On Fri, Sep 16, 2016 at 4:39 AM, Jinghui Niu <niujing...@gmail.com> wrote:
> > I have the following code snippet, I marked my question in a comment line
> > inside the h
I have the following code snippet, I marked my question in a comment line
inside the hybrid_property.expression part. As you can see, it is now not
implemented:
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy import Column, Integer, String, Unicode, UnicodeText
from
Hi, I wonder if there is any recommendation or best practice on choosing
between
hybrid_property
and
hybrid_method
,
other than they hybrid_method can take arguments? If I use the
hybrid_method only throughout, without giving it a argument more than self,
doesn't it equal to using
Thanks Mike. In future is it likely to have the instance level expression
and class level expression automatically translated by ORM? It will be so
much easier!
On Mon, Aug 22, 2016 at 7:20 AM, Mike Bayer <mike...@zzzcomputing.com>
wrote:
>
>
> On 08/22/2016 03:20 AM, Jinghui Niu
I'm creating a mixin for my timestamp columns throughout my projects.
Internally, the mixin uses UTC strings to store timestamps, externally it
converts back and forth into local time using a second column that stores
timezone information. I'm studying the hybrid attribute section in the
For clarity I made a table below in my notes out of reading the
documentation and generalize the points:
Engine: no worries, Engine object is always thread safe.
Session: Session objects are tricky, they can be quite dangerous to use in
a multi-threading context if one is not careful. Forget
Oh by the way, I'm using SQLite as backend.
On Aug 14, 2015 2:04 AM, Jinghui Niu niujing...@gmail.com wrote:
I have three different DBs, one is person.db, another is journal.db, yet
another is tag.db. In the documentation it reads:
Vertical partitioning places different kinds of objects
I have three different DBs, one is person.db, another is journal.db, yet
another is tag.db. In the documentation it reads:
Vertical partitioning places different kinds of objects, or different
tables, across multiple databases:
engine1 = create_engine('postgresql://db1')
engine2 =
Thanks for all these helpful feedback.
If I still want to use SQLite, and I still need to do vertical partition,
what can I do? Am I out of luck?
On Friday, August 14, 2015 at 2:04:37 AM UTC-7, Jinghui Niu wrote:
I have three different DBs, one is person.db, another is journal.db, yet
reference. I suppose such feature is relatively commonly needed
among SQLite users isn't it?
On Friday, August 14, 2015 at 3:48:40 PM UTC-7, Jonathan Vanasco wrote:
On Friday, August 14, 2015 at 5:16:48 PM UTC-4, Jinghui Niu wrote:
If I still want to use SQLite, and I still need to do
Thanks Jonathan for pointing out the direction, it is very helpful to know
where I can find more info.
On Friday, August 14, 2015 at 5:06:09 PM UTC-7, Jonathan Vanasco wrote:
Well, this problem doesn't really have anything to do with SqlAlchemy --
you should probably ask people for advice on
:07 PM UTC-7, Jinghui Niu wrote:
Thanks Jonathan for pointing out the direction, it is very helpful to know
where I can find more info.
On Friday, August 14, 2015 at 5:06:09 PM UTC-7, Jonathan Vanasco wrote:
Well, this problem doesn't really have anything to do with SqlAlchemy --
you should
About the Session.merge(), the documentation gives several examples of use
cases, I think there might be a slight ambiguity in this one:
An application which reads an object structure from a file and wishes to
save it to the database might parse the file, build up the structure, and
then use
In the Documentation -- Session Basics, I read this:
E.g. don’t do this:
### this is the **wrong way to do it** ###
class ThingOne(object):
def go(self):
session = Session()
try:
session.query(FooBar).update({x: 5})
session.commit()
/15 5:31 PM, Jinghui Niu wrote:
I know you can set this constraint if you are directly dealing with
sqlite3, but how can I achieve this database level setting from within
sqlalchemy?
The documentation reads:
Note that these clauses are not supported on SQLite, and require InnoDB
tables
I know you can set this constraint if you are directly dealing with
sqlite3, but how can I achieve this database level setting from within
sqlalchemy?
The documentation reads:
Note that these clauses are not supported on SQLite, and require InnoDB
tables when used with MySQL. They may also
I read the documentation and encountered this:
@validates('addresses', include_backrefs=False)
def validate_address(self, key, address):
assert '@' in address.email
return address
What are the key and address in the validate_address function? I can't find
any explanation in our
for example, I'd like to search for keywords foo, bar and possibly but
not necessarily more keywords in the description column of my *Item* class,
so I build a list of such keywords:
[foo, bar],
and then use primitive looping to achieve my goal:
query_obj = session.query(Item)
for k in
property method, I
didn't quite understand it back then, does it relate to the two techniques
you suggested here?
On Sun, Jul 26, 2015 at 11:06 AM, Mike Bayer mike...@zzzcomputing.com
wrote:
On 7/25/15 6:38 PM, Jinghui Niu wrote:
By the way, the database driver that I'm using is SQLite, which
48 matches
Mail list logo