Re: [sqlalchemy] How to map a oracle table with long table name

2013-04-17 Thread evanjon.qiu
Hi Simon, Sorry, my bad. I follow your tips to modify my program. It works. #!/usr/bin/env python # -*- coding:utf-8 -*- from sqlalchemy import create_engine from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey, \ DateTime from sqlalchemy.dialects.oracle import NUMBE

Re: [sqlalchemy] mysql dialect and "contains"

2013-04-17 Thread Randy Shults
Thank you. That makes sense. On Wednesday, April 17, 2013 at 4:27 PM, Michael Bayer wrote: > > On Apr 17, 2013, at 3:37 PM, Randy Shults (mailto:randy.c.shu...@gmail.com)> wrote: > > > Awesome thank you. > > > > So even though the Table object is attached to the metadata that was bound >

Re: [sqlalchemy] mysql dialect and "contains"

2013-04-17 Thread Michael Bayer
On Apr 17, 2013, at 3:37 PM, Randy Shults wrote: > Awesome thank you. > > So even though the Table object is attached to the metadata that was bound to > the engine that uses a mysql connection, I have to explicitly set the dialect > and compile when printing out the literal sql. OK well her

Re: [sqlalchemy] mysql dialect and "contains"

2013-04-17 Thread Randy Shults
Awesome thank you. So even though the Table object is attached to the metadata that was bound to the engine that uses a mysql connection, I have to explicitly set the dialect and compile when printing out the literal sql. When I execute, is this handled seamlessly by the engine? Or do I need to

Re: [sqlalchemy] Logger

2013-04-17 Thread Michael Bayer
the easiest way is to use Python logging directly, where you can specify configurations specific to individual loggers: import logging logger = logging.getLogger("sqlalchemy.engine") handler = logging.handlers.FileHandler("somefile.log") handler.setFormatter(logging.Formatter('%(asctime)s - %(n

Re: [sqlalchemy] views & declarative?

2013-04-17 Thread Michael Bayer
On Apr 17, 2013, at 9:59 AM, James Hartley wrote: > On Wed, Apr 17, 2013 at 6:20 AM, Lele Gaifax wrote: > James Hartley writes: > > Is it possible to map Table instances back to classes defined through > > declarative_base()? > > ...I assume you are asking whether you can map a "view" onto a

Re: [sqlalchemy] How to cache autoloaded tables?

2013-04-17 Thread Michael Bayer
would need to see a working example, however I'd be careful about naming tables ALL_UPPERCASE like that, that means you're dealing with a case-sensitive name. Typically, names should be all lower case, indicating "case insensitive", which is easier to deal with. Seems like there might be mor

Re: [sqlalchemy] Querying using objects

2013-04-17 Thread Michael Bayer
OK, if you want to stick with hybrids, you can define your own "SomeClass.myattribute == someobject" behavior by creating your own comparator, see the docs at http://docs.sqlalchemy.org/en/rel_0_8/orm/extensions/hybrid.html#building-custom-comparators . On Apr 17, 2013, at 7:15 AM, Richard Ge

Re: [sqlalchemy] SQL insert error

2013-04-17 Thread Michael Bayer
On Apr 17, 2013, at 6:53 AM, Philipp Kraus wrote: > Hello, > > I have try to insert some data from a dict into my table and I have used the > description on > http://docs.sqlalchemy.org/en/rel_0_8/core/tutorial.html#insert-expressions > I run this command: > > connect.execute( sqlalchemy.Tab

Re: [sqlalchemy] mysql dialect and "contains"

2013-04-17 Thread Michael Bayer
"concat" is a function that's specific to MySQL. So if you create an expression against contains() without any specification that MySQL is in use, you get a LIKE. When the construct is compiled against the MySQL dialect, same as if it is invoked by an engine that's associated with MySQL, you g

[sqlalchemy] mysql dialect and "contains"

2013-04-17 Thread Randy Shults
Can't seem to find any reference to anyone else having this issue, so it must be something I'm doing incorrectly. In Mysql, the contains operator doesnt seem to be translated properly by the dialect. Docs state the following: contains(other, **kwargs)¶ Implement the ‘contains’ operator.

Re: [sqlalchemy] Re: Session.add doesn't work on Python 3.3.0?

2013-04-17 Thread Michael Bayer
I tested on python 3.3.0 exactly so you might want to check that something is strange with your python 3.3.0 environment. Sent from my iPhone On Apr 17, 2013, at 10:14 AM, Tim Cooijmans wrote: > I did some more testing and it appears to be Python 3.3.0 only. > > Indeed the exact same code wi

[sqlalchemy] Re: Session.add doesn't work on Python 3.3.0?

2013-04-17 Thread Tim Cooijmans
I did some more testing and it appears to be Python 3.3.0 only. Indeed the exact same code with exactly the same SQLAlchemy version works on Python 3.3.1 but not in Python 3.3.0. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe fro

Re: [sqlalchemy] Re: views & declarative?

2013-04-17 Thread Simon King
On Wed, Apr 17, 2013 at 2:59 PM, James Hartley wrote: > On Wed, Apr 17, 2013 at 6:20 AM, Lele Gaifax wrote: >> >> James Hartley writes: >> > Is it possible to map Table instances back to classes defined through >> > declarative_base()? >> >> ...I assume you are asking whether you can map a "view

Re: [sqlalchemy] Re: views & declarative?

2013-04-17 Thread James Hartley
On Wed, Apr 17, 2013 at 6:20 AM, Lele Gaifax wrote: > James Hartley writes: > > Is it possible to map Table instances back to classes defined through > > declarative_base()? > > ...I assume you are asking whether you can map a "view" onto a > Python class using the declarative layer. If so, yes,

[sqlalchemy] Logger

2013-04-17 Thread Richard Gerd Kuesters
Hi all, I wonder if I can log all [and only] SQL statements made to the database (using echo=True), instead of sending the output of my script | program to a file. Cheers, Richard. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscri

[sqlalchemy] Re: views & declarative?

2013-04-17 Thread Lele Gaifax
James Hartley writes: > Starting with the Wiki article on implementing views: > > http://www.sqlalchemy.org/trac/wiki/UsageRecipes/Views > > Is it possible to map Table instances back to classes defined through > declarative_base()? I'm not sure I understand the question, but given the reference

Re: [sqlalchemy] Querying using objects

2013-04-17 Thread Richard Gerd Kuesters
Thank you Mike! In fact, that's not my actual model - it is a little more complex than that (specially the @setter), that's why my curiosity about using hybrids and the possibility to query against an object. Best regards, Richard. On 04/16/2013 09:34 PM, Michael Bayer wrote: On Apr 16, 2

[sqlalchemy] views & declarative?

2013-04-17 Thread James Hartley
Starting with the Wiki article on implementing views: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/Views Is it possible to map Table instances back to classes defined through declarative_base()? I'm using SQLAlchemy 0.7.1. Thanks. -- You received this message because you are subscribed to

[sqlalchemy] SQL insert error

2013-04-17 Thread Philipp Kraus
Hello, I have try to insert some data from a dict into my table and I have used the description on http://docs.sqlalchemy.org/en/rel_0_8/core/tutorial.html#insert-expressions I run this command: connect.execute( sqlalchemy.Table( tablename, metadata ).insert().values( i.keys() ).compile(), **i

Re: [sqlalchemy] How to map a oracle table with long table name

2013-04-17 Thread Simon King
On Wed, Apr 17, 2013 at 2:38 AM, Evan Jon wrote: > Hello all, > > I want to map a table whose name is BAND_ORDER_OF_LOCAL_TESTING. > > class BandOrderOfLocalTesting(Base): > __TABLENAME__ = 'BAND_ORDER_OF_LOCAL_TESTING' > order_id = Column("order_id", Number(18), primary_key=True) > ..

[sqlalchemy] How to cache autoloaded tables?

2013-04-17 Thread Davide Setti
Hi all, i'm trying to avoid to do the expensive autoload every time i access a table. I found this question http://stackoverflow.com/questions/11785457/sqlalchemy-autoloaded-orm-persistence . If i try to do the same i get errors. When i query (select) the Table created using unpickled metadata