directly, SQLAlchemy probably won't understand the
dependency.
Does using a relationship fix your problem?
Simon
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and V
Python, to see which objects in the session are about to be deleted.
This is impossible to do in the general case, but it may work for
simple criteria. It will raise an error if the criteria aren't
supported by the evaluator, but note the warning in the docs that "the
expression evaluator current
ime >= starttime, Orders.ef_time < endtime)
orders_objects = session.query(Orders).filter(condition).all()
Hope that helps,
Simon
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete,
alembic) ?
> Also would it works for unique constraint on multiple column or do we have to
> name them explicitly.
>
Is it important to you to do this via a mixin? declarative_base
accepts a "metadata" parameter, so something like this should work:
metadata = MetaData(naming_con
Here's a version which I *think* does what you want. There are a
couple of things that you might want to note.
First, in your paste, Conversation.user1 and Conversation.user2 are
integer columns, but you are assigning User objects to those
properties. That's not the way SQLAlchemy works - you
On Tue, Aug 28, 2018 at 5:53 PM Simon King wrote:
>
> On Tue, Aug 28, 2018 at 4:32 PM 'Brian DeRocher' via sqlalchemy
> wrote:
> >
> > Hey all,
> >
> > I'm writing some automated tests for some legacy python code using a
> > psycopg2 connection. I'd like
directly to
the connection:
http://docs.sqlalchemy.org/en/latest/orm/session_transaction.html#joining-a-session-into-an-external-transaction-such-as-for-test-suites
Would that work for your situation?
Hope that helps,
Simon
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.s
("error")
...which will give you an exception and a stack trace, so you can see where
these warnings are coming from.
Simon
On Wed, Aug 22, 2018 at 10:37 AM wrote:
> Sorry for my last messy message, here's a better version.
>
> That's a good question actually. If you follow my
I've never used Pandas, so this may not make any sense, but where does
the column "VARIABLE_VALUE" come from? Is it a column in your
dataframe?
Simon
On Wed, Aug 22, 2018 at 8:52 AM wrote:
>
> I get the following warnings, when trying to save a simple dataframe to
&
If you are using SQLAlchemy core, there's this:
http://docs.sqlalchemy.org/en/latest/dialects/postgresql.html#insert-on-conflict-upsert
Does that meet your needs?
Simon
On Tue, Aug 21, 2018 at 3:36 AM Hardik Sanghavi wrote:
>
> Did this get resolved or are we to still
, and then query the appropriate parent table.
Simon
On Sat, Jul 28, 2018 at 7:39 AM Sven wrote:
>
> Hi Mike,
>
> Ok, let's forget everything I said before, it is too confusing.
>
> I propose to start from the table_per_association example:
>
> http://docs.sqlalchemy.org/en/
t/ops.html#alembic.operations.Operations.alter_column.params.postgresql_using
Simon
On Thu, Jul 26, 2018 at 11:47 AM Yingchen Zhang wrote:
>
> use PostgreSQL change column type need `cast` like `ALTER TABLE invite_code
> ALTER COLUMN created_at::timestamp TYPE TIMESTAMP WITH TIME ZONE `,
> but sqlalchemy aut
compare_type parameter to True, or to a
custom callable function. The feature works well in most cases, but is
off by default so that it can be tested on the target schema first. It
can also be customized by passing a callable here; see the section
Comparing Types for details.
"""
Ho
the user and
keyword tables, and doesn't have any other behaviour, you probably
don't want to define it as a mapped class at all. Instead, use the
Table constructor, as in the first example at
http://docs.sqlalchemy.org/en/latest/orm/basic_relationships.html#many-to-many.
If you really do want to treat Us
What does the SQL look like for each of your queries?
Can you produce a standalone script that demonstrates the problem? You
could use my script from
https://groups.google.com/forum/#!topic/sqlalchemy/GNIBQMvMRg8 as a
template.
Thanks,
Simon
On Fri, Jun 1, 2018 at 2:41 PM wrote:
>
&g
)
Simon
On Tue, May 22, 2018 at 12:26 PM, Neethu Abhinav
<neethuabhin...@gmail.com> wrote:
> And can you also help me the imports, that is required to use this tool?
>
>
> On Tuesday, May 22, 2018 at 4:54:03 PM UTC+5:30, Neethu Abhinav wrote:
>>
>> Yes, that
test/
The URIs it expects will be the same ones accepted by
sqlalchemy.create_engine():
http://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls
Hope that helps,
Simon
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please pr
You'll probably need to take this up with the PyInstaller folks
(http://www.pyinstaller.org/support.html). SQLAlchemy uses
pkg_resources entry points to load database dialects, and I don't know
how well PyInstaller supports those.
Sorry,
Simon
On Mon, May 21, 2018 at 8:02 PM, <bin...@gmail.
nstance will be stored in the session's
identity map. As long as that instance exists in the session,
SQLAlchemy will not construct an instance of the appropriate subclass
(otherwise the session would contain 2 objects representing the same
row in the database, which SQLAlchemy tries to avo
ould be appreciated.
>
It's possible that pyinstaller hasn't included the sqlalchemy_teradata
package in its output. Perhaps adding "--hidden-import
sqlalchemy_teradata" to your command line when building the exe might
help?
Simon
--
SQLAlchemy -
The Python SQL Toolkit and Object
ould use
one of the eager loading options:
http://docs.sqlalchemy.org/en/latest/orm/loading_relationships.html#joined-eager-loading
For example:
import sqlalchemy.orm as saorm
user = User.query.options(saorm.joinedload('area')).get(1)
This would automatically add the join between the u
sa.and_(subs.c.user_id == User.user_id,
User.name == 'joe'),
)
q = (session.query(Channel, User.user_id)
.outerjoin(userjoin))
print q
for (channel, userid) in q.all():
print channel.channel_name, userid
Ho
No, you'll need to convert that to the equivalent SQL.
On Fri, Apr 27, 2018 at 3:14 PM, Jeremy Flowers
<jeremy.g.flow...@gmail.com> wrote:
> But can you still do things like slice(0,5)? Struggling to get that to work
> atm...
>
> On Fri, Apr 27, 2018 at 2:48 PM, Simon King <s
it would help. I'll
> have a dig around.
>
There are a few examples of using text() with the ORM here:
http://docs.sqlalchemy.org/en/latest/orm/tutorial.html#using-textual-sql
session.execute() behaves more like the Core-level
connection.execute(), which is described here:
http:/
what the right SQL syntax should be.
At this point I would echo Mike's question: why can't you just use "text()"?
Simon
On Fri, Apr 27, 2018 at 10:07 AM, Jeremy Flowers
<jeremy.g.flow...@gmail.com> wrote:
> Well the printed oracle sql dialect now works correctly - when I hack it an
> r
the tutorial
at http://docs.sqlalchemy.org/en/latest/orm/tutorial.html.
Hope that helps,
Simon
--
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 htt
t; function instead:
q3 = select([func.max(dst_tab.c.id)])
http://docs.sqlalchemy.org/en/latest/core/selectable.html#sqlalchemy.sql.expression.select
Hope that helps,
Simon
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post
against a sqlite database.
Good luck!
Simon
On Wed, Apr 18, 2018 at 10:21 PM, su-sa <sachdeva.sugandh...@gmail.com> wrote:
> @Mike, Jonathan and Simon - Thank you so much for all your efforts. I hope I
> can fix the problem soon in the dialect :-)
>
> P.s. I have finally bee
Ah, I didn't notice this part of your query:
.filter(..., Partsupp.ps_supplycost ==
session.query(func.min(Partsupp.ps_supplycost)))
I'm not sure exactly what SQL you are aiming for there, but I think
you need to add .correlate (or maybe .correlate_except) to that inner
query.
Simon
On Wed
assumption that they are part of the outer
query.
Simon
On Wed, Apr 18, 2018 at 4:20 PM, su-sa <sachdeva.sugandh...@gmail.com> wrote:
>
> But if I am not mistaken, the from clause of the query is generated by
> SQLAlchemy and the database driver or the dialect has no influence on this
assing by defining them dynamically.
Can you explain why you are trying to create columns and relationships
dynamically? There might be a different way to approach the problem.
Simon
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code
column in subquery.c
>
Where is the traceback raised? On the evaluation of the
"subquery.c.event_timestamp" expression? That wouldn't really make any
sense. Or is it when the query itself is evaluated? We need to see at
least the traceback, or better a script to reproduce.
Simon
--
SQLAlchemy -
Th
ssion management "around" the rest
of your application code, and handle exceptions in just one place.
There's a section in the docs with more details:
http://docs.sqlalchemy.org/en/latest/orm/session_basics.html#session-faq-whentocreate
Hope that helps,
Simon
--
SQLAlchemy -
Session itself or with the mapped Table objects being operated upon.
This connection represents an ongoing transaction, which remains in
effect until the Session is instructed to commit or roll back its
pending state.
"""
Hope that helps,
Simon
--
SQLAlchemy -
The Python SQL To
OK, so what's not working?
On Fri, Feb 16, 2018 at 10:55 AM, <eugene.de...@gmail.com> wrote:
> Yes session.is_active is True.
> I really sure, because i log this operation.
>
> пятница, 16 февраля 2018 г., 13:50:51 UTC+3 пользователь Simon King написал:
>>
>> You
You haven't explained in what way it's not working with your latest iteration.
The last code you posted only called session.close() if
session.is_active was true. Are you sure you really are closing the
session?
Simon
On Fri, Feb 16, 2018 at 10:02 AM, <eugene.de...@gmail.com>
When you say your first execute function doesn't work, what do you
mean? Do you get an error? Do the results not show up in the database?
I don't think there's any need for session.begin()
http://docs.sqlalchemy.org/en/latest/orm/session_api.html#sqlalchemy.orm.session.Session.begin
Simon
/docs/0.12/appcontext/#locality-of-the-context).
Hope that helps,
Simon
On Thu, Feb 15, 2018 at 9:52 AM, <eugene.de...@gmail.com> wrote:
> Hello, Simon!
> So what better way?
> Something like this?
> SESSION = sessionmaker(bind=engine, autocommit=True)
>
>
>
> @decorato
t Core. Can you explain what you're looking
for in more detail?
Thanks,
Simon
--
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://stackoverflo
er. If you are *absolutely certain* that
will never happen, adding the "finally" section will probably improve
things, but I would recommend that you try to structure your app a
little differently, so that the session creation and teardown happen
at the beginning and end of the web request.
Hop
The pattern you should be aiming for is one in which a fresh
transaction is started for every web request that touches the
database, and that the transaction is closed at the end of the
request. How are you ensuring that at the moment?
Simon
On Wed, Feb 14, 2018 at 12:51 PM, <eugene
PYTHONPATH that is being imported
instead of the real library?
Simon
On Tue, Feb 13, 2018 at 3:58 PM, su-sa <sachdeva.sugandh...@gmail.com> wrote:
> Hi Simon,
>
> I installed both pytest and mock using pip install py.test mock in the
> virtualenv. I am using anaconda python. B
ars):
for c in chars:
col = sa.func.REPLACE(col, c, '')
return col
def removewhitespace(col):
return removechars(col, '\t\r\n')
print removewhitespace(Jobdtl.jobdtl_cmd)
Hope that helps,
Simon
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www
As you say, .join() produces an inner join by default. You can specify
isouter=True to get a left outer join (or call the .outerjoin method
instead), and full=True to get a full outer join. I think you'd get a
cross join if you just didn't call the .join() method at all.
Simon
On Fri, Feb 9
Out of interest, why would you not write:
print(
session.query(Jobmst.jobmst_type, Jobmst.jobmst_name)
.first()
)
The call to with_entities seems unnecessary.
Simon
On Fri, Feb 9, 2018 at 12:27 PM, Jeremy Flowers
<jeremy.g.flow...@gmail.com> wrote:
> And that can be s
The chaining-friendly method you are looking for is probably with_entities():
http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.query.Query.with_entities
Simon
On Fri, Feb 9, 2018 at 11:52 AM, Jeremy Flowers
<jeremy.g.flow...@gmail.com> wrote:
> From watching your
The main point you should take from Mike's original reply is:
.values() is a weird method and it's pretty old, usually people
just set the columns up front
You probably shouldn't use it.
On Fri, Feb 9, 2018 at 11:45 AM, Jeremy Flowers
wrote:
> Also this didn't
defined, you can add further
restrictions to it simply by calling its ".filter()" method.
Alternatively you can convert the query to a subquery and then build
another query around that.
http://docs.sqlalchemy.org/en/latest/orm/tutorial.html#using-subqueries
Hope that helps,
Simon
--
SQLAl
somebody please help me to solve the problem.
>
How have you installed these libraries? Are you using virtualenv? If
so, are pytest and mock both installed in the virtualenv?
Simon
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post exam
are the scope and lifetime of the above vs.
> using a listener as suggested by Michael?
>
I'm pretty sure variables set using "SET GLOBAL" will not survive a
database restart. You'd need to specify it on the server command line
or config file if you wanted it to be persistent.
Simo
nto the history table.
The versioned_rows.py example is more like what you described,
converting what would have been an UPDATE into an INSERT on the same
table.
Both examples use the "before_flush" session event to implement the
versioning, so other parts of your code don't need to be
Yes, if you can't find where you are creating new Satellite instances,
I'd probably stick an assert statement in Satellite.__init__ and see
where it gets triggered.
Simon
On Mon, Jan 15, 2018 at 10:34 AM, Ruben Di Battista
<rubendibatti...@gmail.com> wrote:
> Dear Simon,
>
&g
the results that another thread has written:
https://en.wikipedia.org/wiki/Isolation_(database_systems)#Isolation_levels
https://sqlite.org/isolation.html
https://www.postgresql.org/docs/9.1/static/transaction-iso.html
Simon
On Mon, Jan 15, 2018 at 9:39 AM, <ginger...@gmail.com> wrote:
&
On Sat, Jan 13, 2018 at 3:31 PM, Ruben Di Battista
<rubendibatti...@gmail.com> wrote:
>
>
> On Friday, January 12, 2018 at 10:54:49 AM UTC+1, Simon King wrote:
>>
>> If I understand your code correctly, scheduler.propagate() creates a
>> large number of Passage ins
for that
relationship, and then you'll probably need to explicitly add the
passages you want to *keep* to the session instead.
Hope that helps,
Simon
On Fri, Jan 12, 2018 at 2:10 AM, Mike Bayer <mike...@zzzcomputing.com> wrote:
> I can't give you much detail except to say the unique obje
st be added manually, even for
single table inheritance.
So I guess it's not strictly a bug, and there's probably a good reason
why it's not being done. It might be simply that it's a bit
complicated to implement so it hasn't been done yet.
Simon
--
SQLAlchemy -
The Python SQL Toolkit and Obje
d it up one step at a time, something like this:
q = session.query(YourObject)
if price is not None:
q = q.filter(YourObject.price == price)
if category is not None:
q = q.filter(YourObject.category == category)
if sizes:
q = q.join(Size).filter(Size.size.in_(sizes))
if colors:
d write this in SqlAlchemy?
You ought to be able to build up the above SQL incrementally using the
Query.subquery() method. See the example at:
http://docs.sqlalchemy.org/en/latest/orm/tutorial.html#using-subqueries
If you wanted to use the EXISTS version of the second condition, you
would need something like:
sa.Column(sa.String(16))
__mapper_args__ = {
'polymorphic_on': name,
}
def execute(self, task):
raise NotImplemented
class DoStuffTaskType(TaskType):
__mapper_args__ = {
'polymorphic_on': 'do_stuff_task',
}
def execute(self, task):
# do stu
ate_session,
scopefunc=manager.get_current_tenant)
Base.query = Session.query_property
As long as you call manager.set_current_tenant whenever you switch to
querying a different tenant, this ought to work. But note that all of
this confusion and complexity stems from using scoped sessions and
Bas
per HTTP request, the standard HTTP
> request pattern is one Session per request.There's no problem in
> that case. You mentioned you have some non-flask applications that
> want to communicate with multiple tenants in one Session.
>
OP, can you describe in more detail why these a
/latest/faq/performance.html#i-m-inserting-400-000-rows-with-the-orm-and-it-s-really-slow)
If that still isn't fast enough, I guess you'll need to prepare a data
file and then use the appropriate DB-specific mechanism to load it. I
don't think SQLAlchemy has any specific tools for that.
Simon
on.execute() accepts any Core construct)
Hope that helps,
Simon
On Mon, Nov 20, 2017 at 9:16 PM, Skip Montanaro
<skip.montan...@gmail.com> wrote:
> I've narrowed down my problem space a bit. Consider this simple code:
>
> from sqlalchemy import (Integer, String, Column, MetaData, c
Can you explain why you actually want to do this? There might be
better options than before_flush, but we'd need to know exactly what
you're trying to do first.
Simon
On Thu, Nov 16, 2017 at 12:55 PM, <jens.troe...@gmail.com> wrote:
> That makes sense, thank you, Simon!
>
> Regar
that haven't yet been committed.
There are various ways to do what you want, depending on how your code
is structured. One possibility is to use a Session event such as
before_flush to set a flag saying that there are uncomitted changes in
the database.
http://docs.sqlalchemy.org/en/latest
; (backref_key, self, m))
>> sqlalchemy.exc.ArgumentError: Error creating backref 'parent' on
>> relationship 'Animal.description': property of that name exists on mapper
>> 'Mapper|Description|descriptions'
>>
>>
>> It seems impossible to link the classes to the
On Mon, Nov 13, 2017 at 4:35 PM, Ahmad Javed <ahmadjaved...@gmail.com> wrote:
> Thank you Simon. Appreciate your response. Just using session.remove() at
> the end of each request is not closing the connection and leave open
> connections in MySQL database. One more thing I want
cation starts up. Disposing the engine (or the pool) should never
be necessary.
If all your per-request DB access goes through the scoped session, and
you are calling session.remove() at the end of each request,
connections should be returned to the pool properly.
Simon
--
SQLAlchemy -
The P
en the table. I don't want them to be shared by
> the subclasses.
>
> When I query one of the Concretes, the ACB mapper is updated with the
> "start" and "end" attributes, and then the Concretes are expected to
> implement the attributes on the mapper level(which is n
get_bind_args helper function)
Your overridden version of _execute_and_instances is passing a clause
in the "mapper" parameter, which seems wrong. Somehow you need to fix
that, perhaps by using the _get_bind_args helper.
Simon
On Wed, Oct 25, 2017 at 1:02 PM, Антонио Антуан <a.ch
What does self._mapper_zero() return in your
RoutingQuery._execute_and_instances method?
Simon
On Wed, Oct 25, 2017 at 11:52 AM, Антонио Антуан <a.ch@gmail.com> wrote:
> Any news here?
>
> суббота, 21 октября 2017 г., 18:42:47 UTC+3 пользователь Антонио Антуан
> на
ither be an instance of
sqlalchemy.orm.mapper.Mapper, or None, in which case "if mapper:" is a
valid and concise way to write it. Comparing to None might be strictly
more accurate, but it shouldn't be necessary.
Simon
On Fri, Oct 20, 2017 at 3:17 PM, Антонио Антуан <a.ch@gmail.com> wrote:
> Really,
is point is some
sort of SQL construct (such as a column object or mapped property),
rather than an actual mapper.
You don't say which version of SQLAlchemy you are using, but since
you've overridden _execute_and_instances, I wonder if you need to use
something like query._bind_mapper() as used by _ge
traps.html#executing-the-main-module-twice>
When you import a module, it gets cached in sys.modules under its
"fully qualified module name", so it doesn't matter how many times you
run "import foo", the module is only loaded once.
However, the script that you initially
)
"engine.connect()" will raise an exception if it fails to connect.
Hope that helps,
Simon
--
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
On Fri, Sep 22, 2017 at 9:42 AM, Simon King <si...@simonking.org.uk> wrote:
> On Fri, Sep 22, 2017 at 8:18 AM, John Smith <johnsmith31...@gmail.com> wrote:
>> I have the following database schema:
>>
>> Table "Parent":
>> 1. id - primary key id
parent = relationship(Parent, foreign_keys=[parent_id])
__mapper_args__ = {
'polymorphic_identity':'Child',
'inherit_condition': id == Parent.id,
}
engine = create_engine('sqlite:///:memory:', echo=True)
Session = sessionmaker()
Session.configure(bind=engine)
Base.metadata.create_a
Could you pair a before_commit handler with an after_flush_postexec
handler? The before_commit one would set a flag to say that you are
committing, and the after_flush_postexec one would look for that flag
before proceeding.
Simon
On Fri, Sep 15, 2017 at 12:08 AM, <m...@benchling.com>
b/master/flask_sqlalchemy/__init__.py#L851
Simon
--
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 d
On Thu, Sep 14, 2017 at 10:59 AM, Ankur Kumar
<ankur.kumar.o...@gmail.com> wrote:
>> Hello Simon,
>
>
> Thanks,
> I donot want to read uncommitted data.
>
> I want to read committed data by one API server from another API server.
>>
>>
>
> From an
ysql.com/doc/refman/5.7/en/innodb-transaction-isolation-levels.html
http://docs.sqlalchemy.org/en/latest/orm/session_transaction.html#setting-transaction-isolation-levels
(Obviously with lower transaction isolation comes the possibility of
reading inconsistent data and so on)
Hope that helps,
Si
with a batch sizes of 10, 50 and 100. You'll run more queries but
I suspect each query will perform better.
Simon
On Wed, Aug 30, 2017 at 10:02 PM, Ken MacKenzie <deviloc...@gmail.com> wrote:
> With a batch size of 1 based on the original selection, no improvement.
>
> I am going
query and potentially leave you open to
SQL injection.
d) Are your values unicode strings or byte strings? If unicode, does
the encoding match what the database expects?
If none of those are issues for you, the textual version is probably
pretty safe.
Simon
On Wed, Aug 30, 2017 at 5:30 PM, Ken
'),
)
statement = sa.delete(table, whereclause=condition)
batchparams = [{'pk1': v[0], 'pk2': v[1]} for v in id_batch]
session.execute(statement, batchparams)
Simon
On Wed, Aug 30, 2017 at 4:28 PM, Ken MacKenzie <deviloc...@gmail.com> wrote:
> After the current sorted profile finishes I wi
(id_batch) * len(cls.SQL_PK)?
You could try playing with your batch sizes to see what sort of effect that has.
Simon
On Wed, Aug 30, 2017 at 4:01 PM, Ken MacKenzie <deviloc...@gmail.com> wrote:
> So I implemented this version with one change. I moved this line:
>
> cols = [getat
Textual SQL is not DB-neutral in general. Luckily, in this case you
shouldn't even need it. Try something like this:
for x in id_batch:
cols = [getattr(cls, colname) for colname in cls.SQL_PK]
pkf = [(col == v) for (col, v) in zip(cols, x)]
and_cond = and_(*pkf)
or_cond.append(a
or refactor (b/c commit happens via a decorator).
>
> # Main question
>
> Why does this happen exactly for multiple records and why did this work in
> 1.0 but does not in 1.1?
What platform are you running this on, and how have you installed
MySQLdb and SQLAlchemy? If you ugraded SQLAlchemy
Are you flushing the same session that was used to load the record?
What session does get_instance use?
Simon
On Mon, Aug 21, 2017 at 7:47 AM, pravin battula
<pravin.batt...@gmail.com> wrote:
> I did as below. But didn't work. Am i missing anything else.
>
> def update_rec
No, but you can trivially write your own function to do it:
def updateobj(obj, data):
for key, value in data.items():
setattr(obj, key, value)
Simon
On Fri, Aug 18, 2017 at 3:14 PM, pravin battula
<pravin.batt...@gmail.com> wrote:
> The solution which you gave will work b
but:
product_live_item.attr1 = value1
product_live_item.attr2 = value2
session.flush()
Is that what you meant?
Simon
--
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
o you mean the amount of typing you
have to do each time you disable a column (creating the hybrid
properties)? If so, you might be able to use the events system to
create those properties automatically. For example, you could try
listening for the "after_configured" mapper event, then inspect the
cla
;FAIL").join(Main).all())
>
I haven't run your code, so this answer may not be appropriate, but in
general, you can create a relationship when using classical mappings
by passing a "properties" parameter to the mapper() function,
something like this:
mapper(TempTable,
temp_tabl
, you could use ORM events
(http://docs.sqlalchemy.org/en/latest/orm/events.html) to be notifed
when an instance is inserted/updated/deleted.
Hope that helps,
Simon
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please
king
around with pdb in the scalar() function:
https://bitbucket.org/zzzeek/sqlalchemy/src/8d740d6bd6b8bcc061713443120c67e611cdcb34/lib/sqlalchemy/engine/result.py?at=rel_1_1_11=file-view-default#result.py-1212
Simon
On Tue, Jul 4, 2017 at 2:39 PM, Paul Morel
<paul.mo...@tartansolutions.com>
n't, it has to construct those objects and link
them together. Processing 22352 rows in 0.91 seconds doesn't seem bad
to me.
If you can reply with the bare PG and SA core timings, we may have a
better idea of how to optimise your query.
Simon
--
SQLAlchemy -
The Python SQL Toolkit and Object R
t/search.html?q=%22stored+procedure%22_keywords=yes=default
If not, how would you normally call the stored procedure if you
weren't using SQLAlchemy?
Simon
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide a
t for the property value, but
instead to use something that will notify SA when its contents change.
SA has an extension that provides MutableDict and MutableList classes,
as well as tools to build your own more specialized types:
http://docs.sqlalchemy.org/en/latest/orm/extensions/mutable.html
H
You might be interested in this thread:
https://groups.google.com/forum/#!msg/sqlalchemy/8z0XGRMDgCk/tazeIUsdDgAJ
Simon
On Thu, Jun 15, 2017 at 1:53 PM, 'mike waites' via sqlalchemy
<sqlalchemy@googlegroups.com> wrote:
> Interestingly I've just discovered the concept of Bundle
e)
managed_teams = relationship(
'Team',
secondary=user_team_association_table,
primaryjoin=sa.and_(user_team_association_table.c.user_id == id,
user_team_association_table.c.is_manager==sa.true()),
)
Simon
On Thu, Jun 15, 2017 at 12:26 PM, <jens.troe...@gma
Table objects put columns under the ".c" attribute, so you probably
need "user_team_association.c.is_manager".
Simon
On Thu, Jun 15, 2017 at 12:11 AM, <jens.troe...@gmail.com> wrote:
> Thank you Mike, the composite joins look like something close to wha
201 - 300 of 921 matches
Mail list logo