Hi,
does anyone know the syntax of
SELECT COUNT(*) FROM table_name;
for SQLAlchemy? Is there a list of functions (used in SELECT statement)
that exist in SQL that I can use in SQLAlchemy? btw, I am using MySQL.
I need to see if my table is empty (isemty function doesn't work).
Thanks!
milena wrote:
I have tried
select([func.count(*)], from_obj=[table_name]).execute()
but it didn't work
I suppore you're not using mappers, so this is the fastest method:
number_of_rows = table.count().execute().fetchone()[0]
where table is the table object
I have tried
select([func.count(*)], from_obj=[table_name]).execute()
but it didn't work
I think you should try to specify a column in your count or leave it empty
(didn't try). If you're using mapped objects, you can use the SelectResults
extension:
from sqlalchemy.ext.selectresults
Michael Bayer wrote:
to have aliases of properties that are usable with get_by(), use the
synonym function, described in:
http://www.sqlalchemy.org/docs/adv_datamapping.myt#advdatamapping_properties_overriding
Thank you. Altough the docs are very well done, there are many APIs and
that
Micheal Bayer wrote:
id rather just add another plugin point on MapperExtension
for this, which takes place before the polymorphic decision
stage at the top of the _instance method, like
get_polymorphic_identity(). that way you could do all of
this stuff cleanly in an extension (and id do
Michael Bayer ha scritto:
if you can pickle the object by itself, then id guess youre using lazy
loaders with the query.options(lazyload('something')) call, which
places per-object lazy loaders (i.e. callables) on your objects.
I'm not sure, since I never use lazy loaders (I use Twisted).
On 1/15/07, Michael Bayer [EMAIL PROTECTED] wrote:
2. no support for CASCADE in the DROP statement right now. someone
fill me in, is DROP CASCADE part of the sql standard ?
yes, at least for tables.
--~--~-~--~~~---~--~~
You received this message because you
Hi.
I don't know if this already implemented or planned.
Schemas are supported by SQLAlchemy, but unfortunately not all database
supported by SQLAlchemy supports schema.
My idea is simple.
1) When the database does not support schema, the schema name specified
in Table costructor should
On Jan 15, 2007, at 12:05 PM, Manlio Perillo wrote:
My idea is simple.
1) When the database does not support schema, the schema name
specified
in Table costructor should be prepended to the table name.
foo = Table('foo', ..., schema='bar')
result in a table named bar_foo
why
at this point the entity_name should get set after your custom
create_instance is called (at least thats in the trunk). init_attr
is not required, it pre-sets attributes on the object that are
otherwise auto-created later (but the autocreation step throws a
single AttributeError per
in continuing
http://groups.google.com/group/sqlalchemy/browse_thread/thread/4dab6cfae1f62521/8b66851007c6a652?lnk=gstq=daniel+millerrnum=2#8b66851007c6a652
, which bizarrely GG will not let me continue, on a closely related but
not exactly the same issue, i broke my limit of people expecting
Hi Folks,
I have an application that needs to do a certain amount of housekeeping when
objects are deleted or edited. Essentially, I need to keep historical data, so
under some circumstances deleted objects actually need to be obsoleted, and
edited objects need to be copied and references to
12 matches
Mail list logo