Hey Michael,
I really appreciate all that, it was extremely informative. For the
academic sake I have this
extrapolated to include all the actual intermediate tables that TableB
would include.
For the academic sake, without the mixin and proxy, given a traditional
approach where TableA
is
I have about a dozen tables with an id PK column and a single column
with some unique string. I then have a single table that composes 13
rows with an id PK field and all FK refs to rows in the other 12 tables.
Bulk inserting data into the initial 12 tables is simple but I am not
certain
how to
Hey Michael,
Lets say I have a table TableA:
class TableA(Base):
__tablename__ = 'table_a'
id = Column(Integer, primary_key=True)
name = Column(String(collation='nocase'), unique=True, nullable=False)
Then TableB:
class TableB(Base):
__tablename__ = 'table_b'
id =
I don’t understand. Do you mean at the configuration level? e.g.:
class TableB(Base):
# …
name = relationship(TableA) # “name_id” is auto created?
Right,
So when a person is adding rows to TableB, they have a few ways of doing it.
1. If they know or lookup the actual PK
For a trigger template something like:
trg_template =
CREATE TRIGGER trg_foo_{0}
AFTER {0} ON foo
FOR EACH ROW
BEGIN
...
END;
Why does the following not work to remove some redundant boiler plate code:
for x in 'UPDATE', 'INSERT', 'DELETE':
event.listen(
You've been bitten by a Python gotcha!
http://docs.python-guide.org/en/latest/writing/gotchas/#late-binding-closures
Ugh, thanks Simon, moment of careless haste in thinking about this.
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To
I have scenario where I have a TableA that contains rows with with an
optional reference to TableB.
That foreign key column in TableA has triggers and constraints enforcing
either one null or many
with unique references.
When I query for rows I need to select either rows with a reference that
, at 2:16 PM, Joseph Casale jcas...@gmail.com wrote:
While not utilizing newer methods, this produced the desired effect:
query =
self.session.query(func.group_concat(TableA.name.op(',')(literal_column('|'.\
join(TableB).\
filter(TableB.table_a_id == TableA.id).\
filter
Thanks Michael,
jlc
On Tue, Nov 26, 2013 at 9:34 PM, Michael Bayer mike...@zzzcomputing.comwrote:
On Nov 26, 2013, at 7:45 AM, Joseph Casale jcas...@gmail.com wrote:
I have a scalar sub query with a predicate that involves a table and
column produced in the
outer query, Company.id
I have a scalar sub query with a predicate that involves a table and column
produced in the
outer query, Company.id for example. The only way I could include the query
was to write
it out literally and add it as a column with literal_column.
query = session.query(Company, City, ...,
While not utilizing newer methods, this produced the desired effect:
query =
self.session.query(func.group_concat(TableA.name.op(',')(literal_column('|'.\
join(TableB).\
filter(TableB.table_a_id == TableA.id).\
filter(TableB.col == some_val).\
one()
--
You received this
://docs.sqlalchemy.org/en/rel_0_9/core/events.html?highlight=after_create#sqlalchemy.events.DDLEvents.after_create
On Nov 21, 2013, at 8:02 PM, Joseph Casale jcas...@gmail.com wrote:
Is it possible to construct a listener for this event, such that once all
DDL has been run, some
custom DLL statement(s
I have some sqlite tables such as:
CREATE TABLE table_a (
id INTEGER NOT NULL,
table_b_id INTEGER NOT NULL,
name VARCHAR,
PRIMARY KEY (id),
FOREIGN KEY(table_b_id) REFERENCES table_b (id) ON DELETE CASCADE
);
CREATE TABLE table_b (
id INTEGER NOT NULL,
table_c_id INTEGER NOT NULL,
name VARCHAR,
I am trying to write a convenience wrapper something like:
def wrapper(self, arg_a=None, arg_a=None):
query = self.session.query(Table_A).\
filter(Table_A.col_a == arg_a, Table_A.col_b == arg_b).\
all()
...
The actual query is much longer, none the
On Sunday, November 24, 2013 3:44:32 PM UTC-7, Michael Bayer wrote
conditonals?
Yeah, the queries are just so long and with all the combinations of possible
criteria it would get out of hand as I have about 6 optional arguments.
Currently I leverage one filter method and use eval on formatted
Is it possible to construct a listener for this event, such that once all
DDL has been run, some
custom DLL statement(s) could be run without tying these to a specific
table for example?
Something like what @event.listens_for(Engine, 'connect') does but, but
only after create just
before the
Hi Michael,
idm_rw.py is simply a class that is fed stdin and processes and returns the
input via stdout.
The sqlalchemy imports at the top are leveraged within the classes init
method for configuration
queries.
There are two plugins like this, each one is invoked in a fresh process and
loads the
I have a module I wrote that seems to emit this error during import of some
of its table classes
when concurrency gets high. The application that uses this module fires up
an interpreter session
for each Python script that leverages the import.
When not under load or importing manually at the
in addition to the main application thread.
On Oct 20, 2013, at 11:04 PM, Joseph Casale jcas...@gmail.com wrote:
I have a module that is imported by several Python scripts run by an
application
that fires up a new interpreter session for each invocation. When not
under load or
running
itself should occur before the
application starts any threads in addition to the main application thread.
On Oct 20, 2013, at 11:04 PM, Joseph Casale jcas...@gmail.com wrote:
I have a module that is imported by several Python scripts run by an
application
that fires up a new interpreter
I have a module that is imported by several Python scripts run by an
application
that fires up a new interpreter session for each invocation. When not under
load or
running the code manually at the cli things work fine but once the
concurrency
raises and the application starts seeing some load it
I have a module I import which has some table defs and
global sessionmaker() instance.
If the module is ran directly, it executes a create_all() to build a new db.
I am trying to add a trigger DDL event listener:
trg = DDL('...')
event.listen(
SomeName.__table__, 'after_create',
you need to pass a Python callable function (def or lambda, typically) to
event.listen, which
it will call when the event occurs. right now you're just running the
execute() before the listen()
is even called:
event.listen(table, after_create, lambda *args:
trg.execute(bind=engine))
23 matches
Mail list logo