d ensure that "model" is a long lived object , e.g. a mapped
> class. If it's an aliased() object, I'd make sure to use the same
> aliased() object each time.
>
Adding an additional positional argument to augment the cache key worked
perfectly for my use case. I am indeed using a s
rnative approach that would
allow me to continue to use baked queries while not having to implement a
separate *_entities_created() for every model I'm interested in?
The next problem would then be how to refer to model.created_at within the
filter clause. Can that be handled with a bindparam too?
Yes, sorry I didn't follow up
On Mon, Mar 15, 2021 at 12:28 PM Simon King wrote:
> I haven't followed your code in detail, but I think the problem might be
> here:
>
> clazz = school.Class('12', 'A')
>
> students = [
> Student("Name1", "Sname1", clazz=clazz, code='aa7'),
>
.
I can hack something together with a superclass, but though I would mention
here in case someone has a cleaner solution.
Cheers, Scott
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop re
quot;namespaced sequence factory" which I think
might be cool. I’ll post it to the group here if it works out.
Thanks again,
Scott Colby
On Oct 4, 2019, 19:12 -0400, Mike Bayer , wrote:
>
>
> On Fri, Oct 4, 2019, at 3:57 PM, Scott Colby wrote:
> > Hello,
> >
> > I am att
`RETURNING`
clause or `SELECT FOR UPDATE` but I would prefer to only have one
code path for PostgresSQL and SQLite (and others?) if possible.
Unfortunately, I'm stumped as how to do this. What is the right
approach to implement this pattern?
Thank you,
Scott Colby
--
SQLAlchemy -
The Python SQL To
On Monday, August 19, 2019 at 9:58:19 AM UTC+10, Mike Bayer wrote:
>
>
>
> On Sun, Aug 18, 2019, at 6:50 PM, Scott wrote:
>
> Looking to use Alembic to manage migrations.
>
> We currently have different database names in each environment, so for
> dev, test and p
the environment suffix?
Thanks, Scott
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sqlalchemy-alembic+unsubscr...@googlegroups.com.
To view this
,
_sqlite3_Connection):
# emit our own BEGIN
logger.debug('emitting our own BEGIN to work around pysqlite bug')
connection.execute('BEGIN')
My only other question is, for future debugging, where should I log to get
*all* the SQL that is ultimately passed to the database?
Thanks,
Scott
to
use here, but that is how the real code works and I want to test in a
similar environment; additionally, when I tried this whole exercise with a
normal `sessionmaker`, all these problems happened in an identical manner.)
Thanks,
Scott Colby
--
SQLAlchemy -
The Python SQL Toolkit
I think it's easier to explain in an example than for me to waffle on
trying to explain myself :)
from sqlalchemy import Column, ForeignKey, Integer, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, Session
Base = declarative_base()
>
>
> It's possible that if you're using the session in "autocommit" mode and
> just want to occasionally "broadcast" your object state to a quick
> "flush everything", that in fact turning off the "accounting" feature
> with this flag is appropriate. I'm looking at this code and it really
Hi Mike
Thank you for your quick and thoughtful response as usual!
> so the quick and dirty approach is a flag I'm not enthused about,
> nevertheless I don't plan on removing, called
> _enable_transaction_accounting,
>
Yes I saw this when poking around in the source code - it does seem like
Hello all,
Short summary of my question:
Is it possible to stop rollback() from expiring dirty objects?
Specifically, in the case where there are
- local changes made outside to mapped objects outside of a transaction
- flush() is called
- the flush fails
In this case SQLAlchemy will
(Chris's colleague here)
On Thursday, 2 April 2015 17:23:13 UTC+1, Michael Bayer wrote:
this issue is fixed for 0.9.10 and 1.0.0b5, you can test now using either
latest master or the rel_0_9 branch.
Just wanted to say thank you very much for the prompt fix; I continue to be
amazed at
I have an intermediate model which I am using to keep track of which labs
to include since individual labs can be removed.
So when you add a new intermediate model (AgendaModel) it automatically
adds all of the labs.
with
@event.listens_for(Agenda.modules, 'append')
But there is a UNIQUE
then see that by just
getattr(someobj, “somekey”).
On Jul 15, 2014, at 3:40 PM, Scott Meisburger smeis...@gmail.com
javascript: wrote:
I've got an app where through an admin interface, a user can delete
objects in the database. This happens via:
db.session.delete(obj)
db.session.commit
I have a Many-to-Many relationship that I would like to keep track of the
order. I am wondering if I can automatically populate the module_position
field based on the current number of AgendaModule's for an Agenda.
class AgendaModule(db.Model):
__tablename__ = 'agenda_modules'
Hi,
A user of my applicable is getting a unable to open database file None
None error because the file path to their database has a Á character in
it. It works fine if the character is removed, but that is not a good
solution.
Does anyone know how to solve this?
Thanks,
Scott
--
You
works:
if filename != ':memory:':
filename = os.path.abspath(filename)
I am going to file a bug report to see if this should/could be changed (I'm
not sure if there are any downsides to removing these lines).
Scott
On Thursday, June 19, 2014 12:48:57 PM UTC-6, Michael Bayer wrote
Ah great, that is much better than having to modify sqlalchemy code.
Indeed, the below code works for me:
os.chdir(os.path.dirname(db_path))
e = create_engine(sqlite:///, creator=lambda:
sqlite3.connect(os.path.basename(db_path)))
Thanks!
Scott
On Thu, Jun 19, 2014 at 2:09 PM, Mike Bayer mike
() class.
I would be grateful for any insights on how the sequence might
have become out of sync or anything I can change in the code
to prevent it from happening again.
Thank you for your consideration.
Scott
P.S. I should add that I am using cx_Oracle and the connection
string
oracle+cx_oracle
...@zzzcomputing.comwrote:
On Mar 24, 2014, at 2:09 PM, Philip Scott safetyfirstp...@gmail.com
wrote:
Is this a bug, or perhaps some expected side effect of the joined load?
seemed like something that might be possible but the scalar loader is
initializing the attribute to None to start
at 1:06 PM, Michael Bayer mike...@zzzcomputing.comwrote:
On Mar 25, 2014, at 7:48 AM, Philip Scott safetyfirstp...@gmail.com
wrote:
Ah, so, it turns out to be more subtle than I first thought. It took me
quite a while to narrow it down to an easily reproducible case. To trigger
the behavior
Hello all,
I am trying to optimize a query I have, and have noticed some strange
behavior. I have a table called 'Trade'. A trade may optionally have a
commission, which itself is a trade. This is the core of it:
class Trade(Base, CCPTableMixin):
__tablename__= trade
id
Hi folks,
SQLAlchemy is at the heart of what we do at work (UK based hedge fund); so
first of all a big thank you; I am not quite sure where we'd be without
you. We would like to give back to the community as much as we can (I tried
to get some of the developers on the company xmas present
this is normal, loading for the base class only hits those columns which
are defined for that base class - it does not automatically fan out to all
columns mapped by all subclasses.
to do so, you can specify with_polymorphic:
Ahh, thank you very much Michael that does do exactly what I want.
declarative_base is just a function that returns a class. In python, a
class is a first class object just like any other. You can do things like
this:
class MyClass(object):
pass
def foo()
return MyClass
my_class_instance = foo()()
In normal use of SQLAlchemy you don't need to think too
I went though the exact same process of discovery that you did Jonathan :)
It does work perfectly but does not get rendered properly when printing out
the queries (possibly even when I set echo=True on the connection, if I
remember correctly)
On Sun, Sep 22, 2013 at 5:44 PM, Jonathan Vanasco
Scott safetyfirstp...@gmail.com
wrote:
Without actually querying the DB or enumerating the types and their
conversions myself which seems a bit naff; psycopg2.extensions.adapt
almost does it but not quite (e.g. you get '2013-09-10'::date when CAST()
gives you 2013-09-10). Any ideas? It's
| Philip - does this help you at all ? I used the ORM to access the
connection and table data in the underlying engine.
Thank you for your help guys, it was very helpful! HSTORE updating does
work nicely; I've ended up using events as Michael suggested, except that I
have hooked into the
Hello again dear list,
I have a mapped class is polymorphic with single table inheritance. I have
a function wired up to the load() SA event. The dictionary in the
InstanceState which is passed to the load event depends on whether I am
querying on the base class or a derived one, which I don't
Thanks Michael
a column_property() against a SQL expression by definition is not
writable. Your table doesn't have a CAST trigger inside of it for when an
int is written to it that would convert it back to a string.
in this case since data is already loaded fully as a single column you
Hi Folks,
So we have a sort of generic table; let's call it 'Thing'. For the sake of
example, let it have two columns. An integer 'id', and a hstore 'data':
from sqlalchemy.dialects.postgresql import HSTORE
from Column, Integer
class Thing(Base):
__tablename__ = 'thing'
id =
On Sunday, 27 January 2013 23:10:20 UTC, Michael Bayer wrote:
On Jan 27, 2013, at 4:42 PM, Scott Sadler wrote:
Hi, I wanted to post here since I had to hack around an issue in order
to use SQLAlchemy with a dynamic Postgres schema, and I wanted to see if
there's a way I can get
Hi, I wanted to post here since I had to hack around an issue in order to
use SQLAlchemy with a dynamic Postgres schema, and I wanted to see if
there's a way I can get the workarounds out of my code.
In my app I'm separating the data by dynamically managing the schemas. The
basic way this is
.__bases__:
ret['polymorphic_on'] = PolymorphicMixin.discriminator
return ret
Thanks,
Scott
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from
is below.
I don't really know enough about the types system to know if this is
something I'm doing wrong or something sqlalchemy is doing wrong, but
it seems to have been introduced in r7154:
http://hg.sqlalchemy.org/sqlalchemy/rev/e409e3adb99f
Thanks!
Scott
$ sqlite3 foo.db
SQLite version 3.6.12
Great, thanks, I found a ticket that was already open for this and
added to it.
http://www.sqlalchemy.org/trac/ticket/1372
On Nov 17, 7:23 am, Michael Bayer mike...@zzzcomputing.com wrote:
scott wrote:
Is there a way to filter a query involving an association_proxy?
For example, say I
(), with tests. I'm happy to post a ticket and
flesh it out more if it seems reasonable.
http://web.mit.edu/storborg/Public/better-associationproxy-filtering.patch
Thanks,
Scott
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
don't really know
what the underlying column name is going to be for each instance of a
composite column type.
session.query(Vertex).order_by(vertices.c.x1)
Thanks,
Scott
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
for this?
Thanks!
Scott
example of (bug?) in adding deferred columns to a declarative class
after the
class's creation.
Foo is a normal declarative class with a deferred column. Bar is the
same class,
but with the deferred column added afterwards.
from sqlalchemy import *
from sqlalchemy.orm
to access a non-foreign key column on the join table to order the
collection by. If there's a better way to do this with the order_by
parameter I'd love to figure it out b/c association object syntax with
ORM gets REALLY messy.
Thanks, Scott
On Mar 10, 12:03 pm, Michael Bayer mike...@zzzcomputing.com
'.
Any advice would be appreciated!
Scott
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email
) NOT NULL,
Category1 CHAR(2),
Category2 CHAR(2)
)
The user I'm connecting with does not have INSERT privileges, so a
DatabaseError is raised when db.Products.first() is called and SA
tries to do the INSERT. Any idea why SA is trying to do this?
Thanks!
Scott
Traceback (most recent call last
=db.Products.c.ManProdCode ==
db.ProductCategory.c.ManProdCode,
secondaryjoin=db.ProductCategory.c.Category1 ==
db.Categories.c.CatCode,
foreign_keys=[db.ProductCategory.c.ManProdCode,
db.ProductCategory.c.Category1])
Cheers,
Scott
On Mar 6, 2:49 pm, Scott Torborg storb
that, it would just
all work out.
Thanks again, I should have rtfm'd better for this one.
scott
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalchemy
, seem to be
ok at that point.
Is there something dumb that I've set up wrong that someone could
point me at? Or is this just a gotcha to be avoided?
thanks,
scott
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
, but in
database2 not database1. Is there a way to do this without defining another
engine? It looks like Table will take a schema in the table name argument
but not another database name.
Thank you,
Scott
--~--~-~--~~~---~--~~
You received this message because you
tables
- in the DB used by the ERP system
- in a new DB on the same MSSQL server
- in a SQLite DB
How easy does SA make it to use data from multiple DBs?
Thank you very much for your help and work on SQLAlchemy,
Scott
--~--~-~--~~~---~--~~
You received this message
.
Scott
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options
51 matches
Mail list logo