[sqlalchemy] Re: rollback not working

2011-01-24 Thread bool
Thanks a lot for bearing with me. explicit execution - uses a Connection, but will autocommit conn = engine.connect() conn.execute(insert into table (a, b, c) values (1, 2, 3)) I still want a clarification about the above case. When we use explicit execution like the

[sqlalchemy] How can I do an eager loading when joining multiple tables?

2011-01-24 Thread Joel Zhou
Hi list, I defined two tables, Users, Orders and Items, where Orders has a foreign key user_id depending on User.id and Items has a foreign key order_id on Order.id. I'd like to do eager loading when joining these three tables by: session.query(Users).join(Users.orders,

[sqlalchemy] Re: select distinct on a relation to an entity with composite primary key

2011-01-24 Thread NiL
thank you very much michael, this is some kind of mind spinning sqla expression !! -- 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

[sqlalchemy] Clearing an already defined mapper

2011-01-24 Thread Massi
Hi everyone, in my script I have to deal with a table whose number of columns can change at runtime. Since I have no information about the structure I will have to handle at a given moment, I would need to change dynamically the mapping during the program. If I try to re-map the table I obviously

[sqlalchemy] One commit per request

2011-01-24 Thread Franck
Dear all, I'm using the web.py framework, the documentation of which recommends to use SqlAlchemy this way : http://webpy.org/cookbook/sqlalchemy Basically a load hook is loaded before the actual request is processed. However : 1) They recommend to bind scoped_session at every request, which

Re: [sqlalchemy] Re: rollback not working

2011-01-24 Thread Michael Bayer
On Jan 24, 2011, at 5:46 AM, bool wrote: Thanks a lot for bearing with me. explicit execution - uses a Connection, but will autocommit conn = engine.connect() conn.execute(insert into table (a, b, c) values (1, 2, 3)) I still want a clarification about the above

Re: [sqlalchemy] Clearing an already defined mapper

2011-01-24 Thread Michael Bayer
On Jan 24, 2011, at 6:55 AM, Massi wrote: Hi everyone, in my script I have to deal with a table whose number of columns can change at runtime. Since I have no information about the structure I will have to handle at a given moment, I would need to change dynamically the mapping during the

Re: [sqlalchemy] One commit per request

2011-01-24 Thread Michael Bayer
On Jan 24, 2011, at 7:17 AM, Franck wrote: Dear all, I'm using the web.py framework, the documentation of which recommends to use SqlAlchemy this way : http://webpy.org/cookbook/sqlalchemy Basically a load hook is loaded before the actual request is processed. However : 1) They

Re: [sqlalchemy] How can I do an eager loading when joining multiple tables?

2011-01-24 Thread Michael Bayer
On Jan 24, 2011, at 5:54 AM, Joel Zhou wrote: Hi list, I defined two tables, Users, Orders and Items, where Orders has a foreign key user_id depending on User.id and Items has a foreign key order_id on Order.id. I'd like to do eager loading when joining these three tables by:

Re: [sqlalchemy] Adjacency List Relationship in a Child Class

2011-01-24 Thread Michael Bayer
yeah always send us the error message with these since otherwise we have to replicate it , as this mapping looks entirely fine. it asks for a primaryjoin, and additionally the id column, until 0.7.0 is released where this has been fixed, is in terms of Node not Department so you have to

[sqlalchemy] reflecting schema with autoload in Table creation

2011-01-24 Thread Mark Sharp
I am wanting to have SQLAlchemy pull the table schema from the database. I have just started trying to work through Essential SQLAlchemy and believe that I am using a syntax that is no longer supported in SQLAlchemy 0.6.6. This what I have tried: from sqlalchemy import MetaData,

[sqlalchemy] SqlSoup ProgrammingError The data types nvarchar and ntext are incompatible in the equal operator

2011-01-24 Thread Mark Sharp
I decided to try to get some reflection using SqlSoup on a MS SQL Server 2008 database. This is a copy of my session with the DSN obfuscated. from sqlalchemy.ext.sqlsoup import SqlSoup engine1 = SqlSoup(mssql+pyodbc://mydsn) valid_species = db.valid_species.all() Traceback (most recent call

Re: [sqlalchemy] reflecting schema with autoload in Table creation

2011-01-24 Thread Michael Bayer
On Jan 24, 2011, at 5:45 PM, Mark Sharp wrote: I am wanting to have SQLAlchemy pull the table schema from the database. I have just started trying to work through Essential SQLAlchemy and believe that I am using a syntax that is no longer supported in SQLAlchemy 0.6.6. This what I have

Re: [sqlalchemy] SqlSoup ProgrammingError The data types nvarchar and ntext are incompatible in the equal operator

2011-01-24 Thread Michael Bayer
that's weird since I don't have that issue testing against a 2008 database. I can't actually reproduce it. You might want to try ensuring you're on a recent Pyodbc build. You can also try this: from sqlalchemy import create_engine from sqlalchemy.ext.sqlsoup import SqlSoup db =

Re: [sqlalchemy] reflecting schema with autoload in Table creation

2011-01-24 Thread Mark Sharp
Michael, I had missed calling MetaData, but after making the call, I get the following traceback. from sqlalchemy import MetaData, create_engine, Table meta = MetaData() engine1 = create_engine(mssql+pyodbc://mydsn) valid_species_table = Table( ... 'tf_valid_species', meta, autoload =

Re: [sqlalchemy] SqlSoup ProgrammingError The data types nvarchar and ntext are incompatible in the equal operator

2011-01-24 Thread Mark Sharp
Michael, pyodbc.version returns 2.1.8 I tried your code snippet with the same results. I am going to try creating some tables and see how that goes. Mark R. Mark Sharp, Ph.D. msh...@sfbr.orgmailto:msh...@sfbr.org On Jan 24, 2011, at 6:33 PM, Michael Bayer wrote: that's weird since I don't

Re: [sqlalchemy] SqlSoup ProgrammingError The data types nvarchar and ntext are incompatible in the equal operator

2011-01-24 Thread Michael Bayer
Here's a script that runs fine for me on Windows as well as OSX using SQL Server 2008 with pyodbc 2.1.4, I also tried 2.1.8 on OSX without issue (on OSX you need to pass '' and not u''). Try it on yours, and if you continue to get the NTEXT error you may have to report this issue to the pyodbc

Re: [sqlalchemy] SqlSoup ProgrammingError The data types nvarchar and ntext are incompatible in the equal operator

2011-01-24 Thread Mark Sharp
This is the result that I received. conn = pyodbc.connect(DSN=frankie-w7-animal-sa;UID=sa;PWD=select $ from Bill) cursor = conn.cursor() cursor.execute(u ... SELECT [COLUMNS_1].[TABLE_SCHEMA], ... [COLUMNS_1].[TABLE_NAME], ... [COLUMNS_1].[COLUMN_NAME], ...

Re: [sqlalchemy] SqlSoup ProgrammingError The data types nvarchar and ntext are incompatible in the equal operator

2011-01-24 Thread Michael Bayer
you have a trailing comma at the end of the statement. its a long string probably easier to paste it into a .py file and run that. On Jan 24, 2011, at 9:06 PM, Mark Sharp wrote: This is the result that I received. conn = pyodbc.connect(DSN=frankie-w7-animal-sa;UID=sa;PWD=select $ from

Re: [sqlalchemy] SqlSoup ProgrammingError The data types nvarchar and ntext are incompatible in the equal operator

2011-01-24 Thread Mark Sharp
Michael, Back to the same error. import pyodbc conn = pyodbc.connect('DSN=frankie-w7-animal-sa;UID=sa;PWD=select $ from Bill') cursor = conn.cursor() cursor.execute(u ... SELECT [COLUMNS_1].[TABLE_SCHEMA], ... [COLUMNS_1].[TABLE_NAME], ... [COLUMNS_1].[COLUMN_NAME], ...

Re: [sqlalchemy] SqlSoup ProgrammingError The data types nvarchar and ntext are incompatible in the equal operator

2011-01-24 Thread Michael Bayer
great. report it to pyodbc, since I have no idea what configuration you have which would cause that: http://groups.google.com/group/pyodbc On Jan 24, 2011, at 9:31 PM, Mark Sharp wrote: Michael, Back to the same error. import pyodbc conn =

[sqlalchemy] Can you declaratively concatenate two columns

2011-01-24 Thread Royce
Hi does anyone know if is possible to declaratively concatenate two columns together which you can later do query's on. E.g. if I wanted to compute a new column course_name made up of CONCAT(course_code,course_name) Base = declarative_base() class Course(Base): __tablename__ = 'Course'

[sqlalchemy] mappers failed to initialize/class name is not defined

2011-01-24 Thread Ryan
I'm using the declarative style and unable to to get a mapper to initialize. Here's a simplified version of the class from client_transaction.py: class ClientTransaction(Base): __tablename__ = 'client_transactions' id = Column(Integer, primary_key=True) client_promotion_id =

Re: [sqlalchemy] Can you declaratively concatenate two columns

2011-01-24 Thread Lenza McElrath
Hey Royce, This sounds like a job for composite columns: http://www.sqlalchemy.org/docs/orm/mapper_config.html#composite-column-types One gotcha that I ran into here is that you cannot have both the component columns and the composite column mapped at the same time, like you do in your example.