Am 18.02.2014 23:20, schrieb Michael Bayer:
good catch, I've rewritten the docs here:
http://docs.sqlalchemy.org/en/latest/dialects/oracle.html#unicode.
The more common approach of using text() is included.
Thanks a lot for the quick reponse and explanations. Your recipe of
specifying
The docstring for the cx-Oracle dialog says:
SQLAlchemy will pass all unicode strings directly to cx_oracle, and
additionally uses an output handler so that all string based result
values are returned as unicode as well.
The latter does no longer seem to be true; the handler was recently
It might be still worthwhile to revisit that example now that
http://www.python.org/dev/peps/pep-0435/ has been accepted.
-- Christoph
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from
Am 23.11.2012 14:34, schrieb philipt:
Psycopg 2.4.6 will support them
(http://initd.org/psycopg/docs/extras.html#range-data-types).
Ranges are quite useful and play well with exclusion constraints.
Yepp. I also often have ranges (not only time ranges) in my databases,
currently implemented
Am 09.11.2012 23:54, schrieb Michael Bayer:
NamedTuple is a tough one - because with our result sets we need to
create a new NamedTuple for every call to execute(), meaning it has
to be performant not just on creating new instances of the tuple,
but on creating new tuple types as well.
If
Query results in SQLAlchemy are returned as named tuples, but SQLAlchemy
uses its own flavor of named tuples which is not fully compatible with
collections.namedtuple in the standard lib. For instance, _fields is
called _labels in SQLAlchemy, and the method _asdict() which could
be helpful to
I'm trying to use SQLAlchemy with a silly legacy database the design of
which I cannot change. In this database, there are parent tables with
foreign key columns which can point to two different tables, depending
on another column in the parent table.
Think for example of a user table with a
Am 31.08.2012 16:07, schrieb Michael Bayer:
right, this is a really common (and IMHO incorrect) design that is
referred to as a generic foreign key or a polymorphic foreign
key. It was popularized by frameworks such as Rails and Django. We
have a recipe that implements this exact schema with
Thanks again for the link to the Polymorphic Associations with
SQLAlchemy article. You're right, that's the same problem I had been
facing. Your generic solution is not applicable for me, because I can't
change the database design, but the elementary solution is good enough.
For the curious,
Am 25.07.2012 07:17, schrieb Amos:
[obj.code for obj in
Session.query(Model).filter_by(my_column=123).all()]
[u'123ad', u'123lpb', u'123xd8', u'123za0']
I would expect no results as no column exactly matches the string
representation of my number
Your result will depend on how your
Am 28.07.2011 00:41 schrieb Michael Bayer:
order_by() is accepting SQL expressions, not values, so it is
consistent that values should be coerced to SQL first in this case
literal_column(1), etc.
My thought was that if order_by automatically coerces strings, i.e.
order_by('1') works, then it
Most databases allow ordinal numbers as expressions in order by clauses,
some even in group by clauses. And in earlier versions of SQLAlchemy it
had in fact been possible to express these as integers, e.g.
query.order_by(1, 3, desc(2)).
However, in version 0.7.1 this yields an SQL expression
Just noticed that the 0.6.6 docs show a name parameter of subquery(),
but it does not yet seem to be available in 0.6.6. There should be a
note that it can only be used in 0.6.7 or 0.7.
-- Christoph
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
I think I just found a regression in 0.6.
When evaluating the following SQL expression
sum(2*(func.length('bla'),))
with SQLAlchemy 0.6beta3 I get a
RuntimeError: maximum recursion depth exceeded
With SQLAlchemy 0.5 this used to work,
except that it was translated to
0 + length('bla')
Michael Bayer schrieb:
I had the idea that since a1 appears to be in the collections of both u1
and u2, it would be arbitrary where a1 ended up after the flush
completed. But that is likely wrong, in that the flush() is going to look
at change events to determine what state changes to
Tefnet Developers schrieb:
I am having a problem here - at one point a one-to-many relation
attribute is not in sync with a backref one (http://dpaste.com/104225/):
I can reproduce this and also like to know whether this is a bug or
simply not supported by the default list instrumentation.
The Session.mapper feature has been marked as deprecated since SA
0.5.5, but it's still available in SA 0.6b1. Does this mean that it
will continue to exist in SA 0.6 final and other 0.6.x releases? I'm
asking because TurboGears 1.x is using this feature. We want to
document migration issues
Michael Bayer schrieb:
its not coming out anytime soon. A whole lot of info on how to create it
yourself is at
http://www.sqlalchemy.org/trac/wiki/UsageRecipes/SessionAwareMapper .
Thanks for the info. We'll probably add an emulation based on that
recipe to TurboGears 1.1.
-- Chris
Andreas Jung schrieb:
Please no implicit magic under the hood. You can have multiple mappers
for the same table. Citing Guido: explicit is better than implicit.
You wouldn't be forced to use that magic, you could still set
__tablename__ explictly. I understand your argument, but otoh
Michael Bayer schrieb:
As far as implicit tablename, it breaks the single inheritance
scenario. but also besides that I made a comment on that here:
http://www.sqlalchemy.org/trac/ticket/1270#comment:2
Thanks, I hadn't seen that. Not quite sure what you mean with single
inheritance
Michael Bayer schrieb:
if Bar inherits from Foo, Foo is mapped to foo_table, Bar has no
table, Bar will be mapped to foo_table as well.
In that case, no implicit name should be set or course. It should only
be set if a name cannot be figured out otherwise.
oh, this is entirely news to me
Michael Bayer schrieb:
ArgumentError: Mapper 'Mapper|User|None' does not have a mapped_table
specified. (Are you using the return value of table.create()? It no
longer has a return value.)
That's a really old error message, and I can see how its less than
perfect so I've just
Michael Bayer schrieb:
your current approach of using classical mappings with Session.mapper
is entirely supported. ...
So without reading the thread, I think declarative would probably be
good, you can use it with Session.mapper if you want, though I view
Session.mapper as somewhat
Hi Michael,
we're just discussing some issues with SQLAlchemy over at the TurboGears
mailing list which appeared because the new SQLAlchemy usage as promoted
in the 0.5 docs differs from the classical usage. We are unsure how to
solve these issues, so I thought it will be best to get some
mraer schrieb:
This simple test fails with error:
DataError: (DataError) unable to parse time None None
Which version are you using?
Your test works for me (except I needed to change Mapper to mapper)
with SA 0.5rc1 and psycopg 2.0.8, Py 2.5, Postgres 8.3.1 on WinXP.
As an aside, you should
Is there a simple way of comparing tuples in the SQLAlchemy query
language, like (User.last_name, User.first_name) ('Joe', 'Doe')?
SQL-wise it is possible (at least with PostgreSQL), but you cannot write
this as a filter expression.
-- Christoph
Is there a simple way of comparing tuples in the SQLAlchemy query
language, like (User.last_name, User.first_name) ('Joe', 'Doe')?
SQL-wise it is possible (at least with PostgreSQL), but you cannot write
this as a filter expression.
Tried the following, but it does not work:
print
This does not work either:
print session.query(User).filter(
text((last_name, first_name) (%(last_name)s, %(first_name)s),
)).params(first_name='Joe', last_name='Doe').all()
Running out of ideas...
-- Christoph
--~--~-~--~~~---~--~~
You received this
Michael Bayer schrieb:
just use the plain string and not text(), and use :paramname as the
bind param format. example is here:
http://www.sqlalchemy.org/docs/05/ormtutorial.html#datamapping_querying_using
Excellent, that works:
print session.query(User).filter(
(last_name,
jrpfinch schrieb:
mapper(Recurring_task, recurring_tasks, properties =
{raiser:relation(Employee_status,
primaryjoin=(recurring_tasks.c.rt_raiser_id==Employee_status.c.emp_id)})
^
SyntaxError: invalid syntax
There is one missing closing bracket. You should use an editor that
helps
Michael Bayer schrieb:
2.3 is definitely not supported in 0.5 unless you can make the case
for it ASAP. nobody has made any case for 2.3 as of yet.
TurboGears 1.0 still supports Py 2.3, but TG 1.0 favors SQLObject
anyway. TG 1.1 which favors SQLAlchemy has also ceased Py 2.3 support.
So
Will Python 2.3 still be supported by SA 0.5? I noticed that
sqlalchemy.ext.orderinglist uses the new decorator syntax.
-- Christoph
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to
Michael Bayer wrote:
I tend to use a CASE statement for this: CASE WHEN x IS NULL THEN 0
ELSE x . We have case() construct for that.
Yes, but that still leaves me with having to code infinity some way.
For your version, use func.coalesce(start, literal_column(timestamp '-
infinity'))
Lukasz Szybalski schrieb:
I think I prefer info dictionary rather then a string. Dict info
which I use already have something like this:
sqlalchemy.Column('DRIVE_TRAIN', sqlalchemy.Unicode(4)
,info={description:DRIVE TRAIN TYPE [AWD,4WD,FWD,RWD]}),
sqlalchemy.Column('FUEL_SYS',
Does SQLAlchemy support comment on column or comments on other
database objects? I expected Column to have a comment keyword, but found
nothing of that kind. Maybe I am missing something?
I find column comments often useful, and though they may not be SQL
standard, they are supported by all
Lukasz Szybalski schrieb:
I started using info dict on a column names in sa file definitions. It
would be nice to save it to db if once could. What db supports
comments and what table name is it?
Oracle and PostgreSQL have the comment on SQL statement. MySQL has a
comment clause for column
In TurboGears 1, requests are encapsulated between a session.begin() and
session.commit() call (or session.rollback(), if there was an error).
Starting with SA 0.4.3, the commit() raises an exception if the
transaction has been already rolled back in the request (explicitly or
due to an
Michael Bayer schrieb:
thats fine...but also why cant you just say try: session.commit()
except: session.rollback(); raise ?
This would raise an error when the session is already inactive. I don't
want an error in this case. On the other hand, if I remove the raise
statement, then errors
Assume I have a class Customers mapped with a contextual mapper to a
table customers and assume the customers have an attribute city.
Now I want to get all different cities of my customers, starting with
'A', ordered alphabetically. In plain SQL this would be:
select distict city from
Michael Bayer wrote:
The basic request to get cities as strings by themselves should be
easy enough as:
select([Customer.city]).distinct().order_by(
Customer.city).execute().fetchall()
That's exactly what I wanted - and yes, that's really easy.
we will eventually have a
If I define a table like that:
Table('t', metadata, Column('c', Integer, primary_key=True))
then SQLAlchemy creates the column c as a SERIAL on PostgreSQL.
Is there a way to tell SQLAlchemy to create an ordinary integer primary
key, without any associated sequence?
-- Chris
Paul Johnston wrote:
Is there a way to tell SQLAlchemy to create an ordinary integer primary
key, without any associated sequence?
Sure... autoincrement=False
Thanks a lot. Found it now in the API docs.
I propose that this (and the fact that it is True by default) be also
Just noticed that from sqlalchemy import * imports all functions from
sqlalchemy.sql.expression, except column and table - is this by
intent or have these only be forgotten?
-- Chris
--~--~-~--~~~---~--~~
You received this message because you are subscribed to
Martin Kaffanke wr9te:
This should normally be done, that all other properties are still there.
Try to make an example script where you have problems, which we can run
if you have troubles here.
You're right. What confused me is that when you do
mapper(User, pg_user, properties={
[EMAIL PROTECTED] wrote:
Firstly when retrieving information using mappers, I have not been very
successful at all in this If someone could offer a 2 line example of
this problem.
Retrieving Email.address if User.name == 'jack'
...
I have the same problem with locating a row and
45 matches
Mail list logo