[sqlalchemy] Oracle Views/DatabaseLink and declarative

2010-02-24 Thread Christian Klinger

Hi,

i need some help/advice in defining my classes with the declarative 
syntax from sqlalchemy.


This is the current situation:

I have one table in my Database which is a Oracle Database Link. The 
name of this Database Link is a...@adr. I created a view for this 
Database Link called unternehmen.


Thats my syntax for the view unternehmen:

class Unternehmen(Base):
 this table is an already existend view in a oracle db
__tablename__ = 'unternehmen'

mnr = Column(String(12), primary_key=True)
name1 = Column(NAME1, String(33))

This works so far... great :)


Ok now a second table comes into the game. The name of this table is
BTeilnehmer. As you can see this table has a ForeignKey to 
Unternehmen.mnr. I use a seperate metadata BaseC for it because i want

to create this table.

BaseC = declarative_base()

class BTeilnehmer(BaseC):
__tablename__ = 'bteilnehmer'

b_id = Column(Integer(12), Sequence('dd_seq'), primary_key=True)
name = Column(String(12))
company_mnr = Column(String(12), ForeignKey(Unternehmen.mnr))

company = relation(Unternehmen,
   backref = backref('unternehmen'))


If i now try to create the table BTeilnehmer with:

BaseC.metadata.create_all(engine)

it gives me this traceback:

So any ideas or suggestions.
Thanks for your help
Christian


yeti:fernlehrgang cklinger$ bin/python create.py
2010-02-24 10:05:59,090 INFO sqlalchemy.engine.base.Engine.0x...3c10 
SELECT USER FROM DUAL

2010-02-24 10:05:59,091 INFO sqlalchemy.engine.base.Engine.0x...3c10 {}
2010-02-24 10:05:59,099 INFO sqlalchemy.engine.base.Engine.0x...3c10 
select table_name from all_tables where table_name=:name and 
owner=:schema_name
2010-02-24 10:05:59,100 INFO sqlalchemy.engine.base.Engine.0x...3c10 
{'name': 'BTEILNEHMER', 'schema_name': 'FLG'}
2010-02-24 10:05:59,185 INFO sqlalchemy.engine.base.Engine.0x...3c10 
select table_name from all_tables where table_name=:name and 
owner=:schema_name
2010-02-24 10:05:59,185 INFO sqlalchemy.engine.base.Engine.0x...3c10 
{'name': 'BTEILNEHMER', 'schema_name': 'FLG'}
2010-02-24 10:05:59,191 INFO sqlalchemy.engine.base.Engine.0x...3c10 
select sequence_name from all_sequences where sequence_name=:name and 
sequence_owner=:schema_name
2010-02-24 10:05:59,191 INFO sqlalchemy.engine.base.Engine.0x...3c10 
{'name': 'DD_SEQ', 'schema_name': 'FLG'}

2010-02-24 10:05:59,214 INFO sqlalchemy.engine.base.Engine.0x...3c10
CREATE TABLE bteilnehmer (
b_id INTEGER NOT NULL,
name VARCHAR(12),
company_mnr VARCHAR(12),
PRIMARY KEY (b_id),
 FOREIGN KEY(company_mnr) REFERENCES unternehmen (mnr)
)


2010-02-24 10:05:59,215 INFO sqlalchemy.engine.base.Engine.0x...3c10 {}
2010-02-24 10:05:59,228 INFO sqlalchemy.engine.base.Engine.0x...3c10 
ROLLBACK

Traceback (most recent call last):
  File create.py, line 37, in module
BaseC.metadata.create_all(engine)
  File 
/Users/cklinger/work/fernlehrgang/lib/python2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/schema.py, 
line 1811, in create_all

bind.create(self, checkfirst=checkfirst, tables=tables)
  File 
/Users/cklinger/work/fernlehrgang/lib/python2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/engine/base.py, 
line 1129, in create
self._run_visitor(self.dialect.schemagenerator, entity, 
connection=connection, **kwargs)
  File 
/Users/cklinger/work/fernlehrgang/lib/python2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/engine/base.py, 
line 1158, in _run_visitor

visitorcallable(self.dialect, conn, **kwargs).traverse(element)
  File 
/Users/cklinger/work/fernlehrgang/lib/python2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/sql/visitors.py, 
line 89, in traverse

return traverse(obj, self.__traverse_options__, self._visitor_dict)
  File 
/Users/cklinger/work/fernlehrgang/lib/python2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/sql/visitors.py, 
line 200, in traverse

return traverse_using(iterate(obj, opts), obj, visitors)
  File 
/Users/cklinger/work/fernlehrgang/lib/python2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/sql/visitors.py, 
line 194, in traverse_using

meth(target)
  File 
/Users/cklinger/work/fernlehrgang/lib/python2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/sql/compiler.py, 
line 831, in visit_metadata

self.traverse_single(table)
  File 
/Users/cklinger/work/fernlehrgang/lib/python2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/sql/visitors.py, 
line 79, in traverse_single

return meth(obj)
  File 
/Users/cklinger/work/fernlehrgang/lib/python2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/sql/compiler.py, 
line 870, in visit_table

self.execute()
  File 
/Users/cklinger/work/fernlehrgang/lib/python2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/engine/base.py, 
line 1812, in execute

return self.connection.execute(self.buffer.getvalue())
  File 

RE: [sqlalchemy] reflecting schema just on a single table

2010-02-24 Thread King Simon-NFHD78
 -Original Message-
 From: sqlalchemy@googlegroups.com 
 [mailto:sqlalch...@googlegroups.com] On Behalf Of Paul Rigor (uci)
 Sent: 24 February 2010 00:23
 To: sqlalchemy
 Subject: [sqlalchemy] reflecting schema just on a single table
 
 Hi,
 
 Is there anyway to use a metadata object just to obtain the 
 schema of a single table? I have a database of hundreds of 
 tables, and calling MetaData.reflect() retrieves the schema 
 for all of the tables.  This unnecessarily uses up memory and 
 incurs additional time for i/o to complete.
 
 Thanks,
 Paul  
 

Yes - see http://www.sqlalchemy.org/docs/metadata.html#reflecting-tables

Hope that helps,

Simon

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



RE: [sqlalchemy] Oracle Views/DatabaseLink and declarative

2010-02-24 Thread King Simon-NFHD78
Christian Klinger wrote:

[SNIP]
 
 Ok now a second table comes into the game. The name of this table is
 BTeilnehmer. As you can see this table has a ForeignKey to 
 Unternehmen.mnr. I use a seperate metadata BaseC for it because i want
 to create this table.
 

Hi,

I don't know if the seperate base class is the cause of your problem,
but you don't have to do that just to be able to create the table. All
metadata.create_all() does is call create() on each of the Table
objects. So you should be able to do something like this to create the
BTeilnehmer table:

BTeilnehmer.__table__.create()

Hope that helps,

Simon

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Re: How to make relation to same table

2010-02-24 Thread flya flya
Yes, this is what I wonder, but my code use orm, declarative_base(), not
mapper, I write these code follow the document's example, it can't work too,
what's wrong with my code?

Base = declarative_base()
class Page(Base):
   __tablename__ = 'pages'
   id = Column(Integer, primary_key=True)
   parent_id = Column('parent_id', Integer, ForeignKey('pages.id'))

   children = relation('Page')
   *parent = relation('Page', remote_side=['pages.c.id'])*

when insert a data, raise the error information:
raise sa_exc.ArgumentError(Relation %s could not determine any local/remote
column pairs from remote side argument %r % (self, self.remote_side))
sqlalchemy.exc.ArgumentError: Relation Page.parent could not determine any
local/remote column pairs from remote side argument
set([sqlalchemy.sql.expression.ColumnClause at 0xa17690c; pages.c.id])


On Wed, Feb 24, 2010 at 3:39 PM, Oliver Beattie oli...@obeattie.com wrote:
 You probably want to take a look at

http://www.sqlalchemy.org/docs/05/mappers.html#adjacency-list-relationships

 On Feb 23, 5:42 pm, flya flya flyafl...@gmail.com wrote:
 here is code:

 Base = declarative_base()
 class Page(Base):
__tablename__ = 'pages'
id = Column(Integer, primary_key=True)
parent_id = Column('parent_id', Integer, ForeignKey('pages.id'))

   children = relation('Page', backref='parent')

 I get error information:
 sqlalchemy.exc.ArgumentError: Page.children and back-reference
 Page.parent are both of the same direction symbol 'ONETOMANY.  Did
 you mean to set remote_side on the many-to-one side ?

 when change the code
 children = relation('Page', backref='parent')
 to
 childen = relation('Page')
 It can work , but I can  only get 'children' no  'parent' from a Page
instant.

 --
 You received this message because you are subscribed to the Google Groups
sqlalchemy group.
 To post to this group, send email to sqlalch...@googlegroups.com.
 To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.comsqlalchemy%2bunsubscr...@googlegroups.com
.
 For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.





-- 
http://www.flyaflya.com

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re: Joining an Aliased Table Ignored

2010-02-24 Thread Affect
This works great! Thanks, Michael.

In a related note, I was wondering why I wasn't able to make this
explicit workaround myself. It is because I don't understand the SA
abstractions well enough. I hope that your upcoming book helps in this
regard (SQLAlchemy: Database Access Using Python). It's too bad that
it's not gonna be here until November.

Cheers,
Ahmed


On Feb 23, 5:57 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 On Feb 23, 2010, at 4:45 PM, Affect wrote:

     work1 = aliased(Work)
     work2 = aliased(Work)
     query = session.query(work1).outerjoin((work2, work1.parent))
     query = query.outerjoin((Owner, work1.owner))

 bug confirmed, this is ticket #1706.

 for now workaround explicitly:

 query = query.outerjoin((Owner, work1.owner_id==Owner.id))

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] server_version_info

2010-02-24 Thread Gregg Lind
Is there a nice way to get server_version_info from an existing
connection or engine?

Right now it looks quite buried in (for pg):
sqlalchemy.database.postgres.PGDialiect().server_version_info(myconnection).

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] server_version_info

2010-02-24 Thread Michael Trier
Hello,

On Feb 24, 2010, at 11:59 AM, Gregg Lind wrote:

 Is there a nice way to get server_version_info from an existing
 connection or engine?
 
 Right now it looks quite buried in (for pg):
 sqlalchemy.database.postgres.PGDialiect().server_version_info(myconnection).
 

The dialect contains the server_version_info, so if you have a connection you 
can get to the dialect through:

connection.dialect.server_version_info

Also the Engine has the dialect.

Michael

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re: Support for IBM AS/400 database

2010-02-24 Thread st...@mailbag.com
Does anyone have a clue on this error?  Is it due to a change in
SQLAlchemy between 0.4.0 and 0.5.8?

-Jim

On Feb 19, 5:02 pm, Jim Steil j...@qlf.com wrote:
 Here is the traceback I get when following that recipe...

   import sqlalchemy
   from sqlalchemy import *
   import ibm_db_sa.ibm_db_sa
 Traceback (most recent call last):
    File stdin, line 1, in module
    File
 c:\python26\lib\site-packages\ibm_db_sa-0.1.6-py2.6.egg\ibm_db_sa\ibm_db
 _sa.py, line 24, in module
      from sqlalchemy import sql, engine, schema, exceptions, logging
 ImportError: cannot import name logging
  

 The recipe is assuming SQLAlchemy 0.4.0.  I'm using 0.5.8.

      -Jim

 On 2/19/2010 5:17 PM, Lukasz Szybalski wrote:

 http://code.google.com/p/ibm-db/wiki/README

  Let us know if it worked for you.

  $ python
  Python 2.5.1 (r251:54863, Oct  5 2007, 13:36:32)
  [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
  Type help, copyright, credits or license for more information.

  import sqlalchemy
  from sqlalchemy import *
  import ibm_db_sa.ibm_db_sa
  db2 = 
  sqlalchemy.create_engine('ibm_db_sa://db2inst1:sec...@host.name.com:5/pydev')
  metadata = MetaData()
  users = Table('users', metadata,

       Column('user_id', Integer, primary_key = True),
       Column('user_name', String(16), nullable = False),
       Column('email_address', String(60), key='email'),
       Column('password', String(20), nullable = False)
  )

  metadata.bind = db2
  metadata.create_all()
  users_table = Table('users', metadata, autoload=True, autoload_with=db2)
  users_table

  IBM_DB DB-API wrapper sanity test

  Question is wether IBM_DB wrapper supports your as400 version. You
  could try. I never found enough time to test the read functionality.
  If you get it done then that would be nice as I have some data that I
  need to read from there.

  Thanks,
  Lucas

  On Fri, Feb 19, 2010 at 4:07 PM, Jim Steilj...@qlf.com  wrote:

  These is definitely more one DB2 driver for the AS/400.  I seem to recall
  seeing that there was working being done with one of them a couple years
  ago, but don't recall which one.  And, I don't know the status.  Maybe a
  better question would be...  Is there anyone else out there using 
  SQLAlchemy
  with DB2 on an AS/400?

      -Jim

  On 2/19/2010 3:13 PM, Michael Bayer wrote:

  On Feb 18, 2010, at 10:36 AM, Jim Steil wrote:

  Hi

  Just wondering if there is support for the IBM AS/400 database using
  SQLAlchemy.

  IBM produces a DB2 driver, dont know if that overlaps with AS/400
  compatibility or not.

      -Jim

  --
  You received this message because you are subscribed to the Google Groups
  sqlalchemy group.
  To post to this group, send email to sqlalch...@googlegroups.com.
  To unsubscribe from this group, send email to
  sqlalchemy+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/sqlalchemy?hl=en.

  --
  You received this message because you are subscribed to the Google Groups
  sqlalchemy group.
  To post to this group, send email to sqlalch...@googlegroups.com.
  To unsubscribe from this group, send email to
  sqlalchemy+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/sqlalchemy?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Re: Support for IBM AS/400 database

2010-02-24 Thread Lukasz Szybalski
I would check with ibm_db_sa mailing list. Maybe their example is out
of date, or there is a fix for it?


Lucas

On Wed, Feb 24, 2010 at 1:51 PM, st...@mailbag.com j...@qlf.com wrote:
 Does anyone have a clue on this error?  Is it due to a change in
 SQLAlchemy between 0.4.0 and 0.5.8?

 -Jim

 On Feb 19, 5:02 pm, Jim Steil j...@qlf.com wrote:
 Here is the traceback I get when following that recipe...

   import sqlalchemy
   from sqlalchemy import *
   import ibm_db_sa.ibm_db_sa
 Traceback (most recent call last):
    File stdin, line 1, in module
    File
 c:\python26\lib\site-packages\ibm_db_sa-0.1.6-py2.6.egg\ibm_db_sa\ibm_db
 _sa.py, line 24, in module
      from sqlalchemy import sql, engine, schema, exceptions, logging
 ImportError: cannot import name logging
  

 The recipe is assuming SQLAlchemy 0.4.0.  I'm using 0.5.8.

      -Jim

 On 2/19/2010 5:17 PM, Lukasz Szybalski wrote:

 http://code.google.com/p/ibm-db/wiki/README

  Let us know if it worked for you.

  $ python
  Python 2.5.1 (r251:54863, Oct  5 2007, 13:36:32)
  [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
  Type help, copyright, credits or license for more information.

  import sqlalchemy
  from sqlalchemy import *
  import ibm_db_sa.ibm_db_sa
  db2 = 
  sqlalchemy.create_engine('ibm_db_sa://db2inst1:sec...@host.name.com:5/pydev')
  metadata = MetaData()
  users = Table('users', metadata,

       Column('user_id', Integer, primary_key = True),
       Column('user_name', String(16), nullable = False),
       Column('email_address', String(60), key='email'),
       Column('password', String(20), nullable = False)
  )

  metadata.bind = db2
  metadata.create_all()
  users_table = Table('users', metadata, autoload=True, autoload_with=db2)
  users_table

  IBM_DB DB-API wrapper sanity test

  Question is wether IBM_DB wrapper supports your as400 version. You
  could try. I never found enough time to test the read functionality.
  If you get it done then that would be nice as I have some data that I
  need to read from there.

  Thanks,
  Lucas

  On Fri, Feb 19, 2010 at 4:07 PM, Jim Steilj...@qlf.com  wrote:

  These is definitely more one DB2 driver for the AS/400.  I seem to recall
  seeing that there was working being done with one of them a couple years
  ago, but don't recall which one.  And, I don't know the status.  Maybe a
  better question would be...  Is there anyone else out there using 
  SQLAlchemy
  with DB2 on an AS/400?

      -Jim

  On 2/19/2010 3:13 PM, Michael Bayer wrote:

  On Feb 18, 2010, at 10:36 AM, Jim Steil wrote:

  Hi

  Just wondering if there is support for the IBM AS/400 database using
  SQLAlchemy.

  IBM produces a DB2 driver, dont know if that overlaps with AS/400
  compatibility or not.

      -Jim

  --
  You received this message because you are subscribed to the Google 
  Groups
  sqlalchemy group.
  To post to this group, send email to sqlalch...@googlegroups.com.
  To unsubscribe from this group, send email to
  sqlalchemy+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/sqlalchemy?hl=en.

  --
  You received this message because you are subscribed to the Google Groups
  sqlalchemy group.
  To post to this group, send email to sqlalch...@googlegroups.com.
  To unsubscribe from this group, send email to
  sqlalchemy+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/sqlalchemy?hl=en.

 --
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To post to this group, send email to sqlalch...@googlegroups.com.
 To unsubscribe from this group, send email to 
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.





-- 
OpenLdap server for User/Client Authentication in 1min.
http://lucasmanual.com/mywiki/OpenLdap#SetupOpenLdapserver.sh

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Slow running

2010-02-24 Thread dusans
Hi. I got this simple query thats running very slow:
Im working on sqlalchemy 0.6 0.6beta1, sqlite3, python 2.5, windows xp

1. I've addet News.[title] to make it run faster, but its still very
very slow

== Code (10 seconds) == :
Session.query(News.title, KernelResults).\
select_from(join(News, KernelResults,
News.news_id == KernelResults.news_id_2)).\
filter(KernelResults.news_id_1 ==
c.news_id).\
filter(KernelResults.kernel_id == 0).\
order_by(desc(KernelResults.similarity))[:
8]

== The SQL (50 miliseconds) ==:
SELECT
news.title AS news_title,
kernel_results.id_row AS kernel_results_id_row,
kernel_results.news_id_1 AS
kernel_results_news_id_1,
kernel_results.news_id_2 AS kernel_results_news_id_2,
kernel_results.similarity AS kernel_results_similarity,
kernel_results .kernel_id AS kernel_results_kernel_id
FROM news
JOIN kernel_results
ON news.news_id = kernel_results.news_id_2
WHERE kernel_results.news_id_1 = 66
AND kernel_results.kernel_id = 0
ORDER BY kernel_results.similarity DESC
LIMIT 8 OFFSET 0

Could someone please help me? im still fresh with sqlalchemy :)

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Re: How to make relation to same table

2010-02-24 Thread Michael Bayer

On Feb 24, 2010, at 6:14 AM, flya flya wrote:

 Yes, this is what I wonder, but my code use orm, declarative_base(), not 
 mapper, I write these code follow the document's example, it can't work too, 
 what's wrong with my code?
 
 Base = declarative_base()
 class Page(Base):
__tablename__ = 'pages'
id = Column(Integer, primary_key=True)
parent_id = Column('parent_id', Integer, ForeignKey('pages.id'))

children = relation('Page')
parent = relation('Page', remote_side=['pages.c.id'])

no quotes unless the [] are in there as well.  See this FAQ entry:  
http://www.sqlalchemy.org/trac/wiki/FAQ#ImusingDeclarativeandsettingprimaryjoinsecondaryjoinusinganand_oror_andIamgettinganerrormessageaboutforeignkeys.




 
 when insert a data, raise the error information:
 raise sa_exc.ArgumentError(Relation %s could not determine any local/remote 
 column pairs from remote side argument %r % (self, self.remote_side))
 sqlalchemy.exc.ArgumentError: Relation Page.parent could not determine any 
 local/remote column pairs from remote side argument 
 set([sqlalchemy.sql.expression.ColumnClause at 0xa17690c; pages.c.id])
 
 
 On Wed, Feb 24, 2010 at 3:39 PM, Oliver Beattie oli...@obeattie.com wrote:
  You probably want to take a look at
  http://www.sqlalchemy.org/docs/05/mappers.html#adjacency-list-relationships
 
  On Feb 23, 5:42 pm, flya flya flyafl...@gmail.com wrote:
  here is code:
 
  Base = declarative_base()
  class Page(Base):
 __tablename__ = 'pages'
 id = Column(Integer, primary_key=True)
 parent_id = Column('parent_id', Integer, ForeignKey('pages.id'))
 
children = relation('Page', backref='parent')
 
  I get error information:
  sqlalchemy.exc.ArgumentError: Page.children and back-reference
  Page.parent are both of the same direction symbol 'ONETOMANY.  Did
  you mean to set remote_side on the many-to-one side ?
 
  when change the code
  children = relation('Page', backref='parent')
  to
  childen = relation('Page')
  It can work , but I can  only get 'children' no  'parent' from a Page 
  instant.
 
  --
  You received this message because you are subscribed to the Google Groups 
  sqlalchemy group.
  To post to this group, send email to sqlalch...@googlegroups.com.
  To unsubscribe from this group, send email to 
  sqlalchemy+unsubscr...@googlegroups.com.
  For more options, visit this group at 
  http://groups.google.com/group/sqlalchemy?hl=en.
 
 
 
 
 
 -- 
 http://www.flyaflya.com
 
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To post to this group, send email to sqlalch...@googlegroups.com.
 To unsubscribe from this group, send email to 
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Re: Joining an Aliased Table Ignored

2010-02-24 Thread Michael Bayer

On Feb 24, 2010, at 10:21 AM, Affect wrote:

 This works great! Thanks, Michael.
 
 In a related note, I was wondering why I wasn't able to make this
 explicit workaround myself. It is because I don't understand the SA
 abstractions well enough. I hope that your upcoming book helps in this
 regard (SQLAlchemy: Database Access Using Python). It's too bad that
 it's not gonna be here until November.

I wouldn't wait for the book.  the varieties of onclause are in the online docs:

http://www.sqlalchemy.org/docs/ormtutorial.html#querying-with-joins



 
 Cheers,
 Ahmed
 
 
 On Feb 23, 5:57 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 On Feb 23, 2010, at 4:45 PM, Affect wrote:
 
work1 = aliased(Work)
work2 = aliased(Work)
query = session.query(work1).outerjoin((work2, work1.parent))
query = query.outerjoin((Owner, work1.owner))
 
 bug confirmed, this is ticket #1706.
 
 for now workaround explicitly:
 
 query = query.outerjoin((Owner, work1.owner_id==Owner.id))
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To post to this group, send email to sqlalch...@googlegroups.com.
 To unsubscribe from this group, send email to 
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.
 

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Slow running

2010-02-24 Thread Michael Bayer

On Feb 24, 2010, at 6:15 PM, dusans wrote:

 Hi. I got this simple query thats running very slow:
 Im working on sqlalchemy 0.6 0.6beta1, sqlite3, python 2.5, windows xp
 
 1. I've addet News.[title] to make it run faster, but its still very
 very slow
 
 == Code (10 seconds) == :
 Session.query(News.title, KernelResults).\
select_from(join(News, KernelResults,
 News.news_id == KernelResults.news_id_2)).\
filter(KernelResults.news_id_1 ==
 c.news_id).\
filter(KernelResults.kernel_id == 0).\
order_by(desc(KernelResults.similarity))[:
 8]
 
 == The SQL (50 miliseconds) ==:
 SELECT
 news.title AS news_title,
 kernel_results.id_row AS kernel_results_id_row,
 kernel_results.news_id_1 AS
 kernel_results_news_id_1,
 kernel_results.news_id_2 AS kernel_results_news_id_2,
 kernel_results.similarity AS kernel_results_similarity,
 kernel_results .kernel_id AS kernel_results_kernel_id
 FROM news
   JOIN kernel_results
   ON news.news_id = kernel_results.news_id_2
 WHERE kernel_results.news_id_1 = 66
 AND kernel_results.kernel_id = 0
 ORDER BY kernel_results.similarity DESC
 LIMIT 8 OFFSET 0
 
 Could someone please help me? im still fresh with sqlalchemy :)

there's nothing apparent which would cause such slowness unless you have a high 
degree of network overhead when your SQLAlchemy application runs, or for 
example one or more of the columns returned represents an enormous text or 
binary field, perhaps.   For 8 rows and a 50ms query the total time spent 
should be in the ballpark of well under 100 ms.




 
 -- 
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To post to this group, send email to sqlalch...@googlegroups.com.
 To unsubscribe from this group, send email to 
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.
 

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Re: Support for IBM AS/400 database

2010-02-24 Thread Jim Steil
I went in to the ibm_db_sa code and made a change to make it compatible 
with 0.5.8.  But, now I'm getting another error that I need to run down 
that is not python-related.  I'm missing db2cli.dll on my system and 
don't know where I'm supposed to get it from.  And, reading about it 
online leads me to believe it is a driver for linux/windows versions of 
db2 and not the AS/400.  But, I'll dig in to that tomorrow.


-Jim

On 2/24/2010 1:58 PM, Lukasz Szybalski wrote:

I would check with ibm_db_sa mailing list. Maybe their example is out
of date, or there is a fix for it?


Lucas

On Wed, Feb 24, 2010 at 1:51 PM, st...@mailbag.comj...@qlf.com  wrote:
   

Does anyone have a clue on this error?  Is it due to a change in
SQLAlchemy between 0.4.0 and 0.5.8?

-Jim

On Feb 19, 5:02 pm, Jim Steilj...@qlf.com  wrote:
 

Here is the traceback I get when following that recipe...

import sqlalchemy
from sqlalchemy import *
import ibm_db_sa.ibm_db_sa
Traceback (most recent call last):
File stdin, line 1, inmodule
File
c:\python26\lib\site-packages\ibm_db_sa-0.1.6-py2.6.egg\ibm_db_sa\ibm_db
_sa.py, line 24, inmodule
  from sqlalchemy import sql, engine, schema, exceptions, logging
ImportError: cannot import name logging
  

The recipe is assuming SQLAlchemy 0.4.0.  I'm using 0.5.8.

  -Jim

On 2/19/2010 5:17 PM, Lukasz Szybalski wrote:

   

http://code.google.com/p/ibm-db/wiki/README
 
   

Let us know if it worked for you.
 
   

$ python
Python 2.5.1 (r251:54863, Oct  5 2007, 13:36:32)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type help, copyright, credits or license for more information.
 
   

import sqlalchemy
from sqlalchemy import *
import ibm_db_sa.ibm_db_sa
db2 = 
sqlalchemy.create_engine('ibm_db_sa://db2inst1:sec...@host.name.com:5/pydev')
metadata = MetaData()
users = Table('users', metadata,
   
   

  Column('user_id', Integer, primary_key = True),
  Column('user_name', String(16), nullable = False),
  Column('email_address', String(60), key='email'),
  Column('password', String(20), nullable = False)
)
 
   

metadata.bind = db2
metadata.create_all()
users_table = Table('users', metadata, autoload=True, autoload_with=db2)
users_table
   
   

IBM_DB DB-API wrapper sanity test
 
   

Question is wether IBM_DB wrapper supports your as400 version. You
could try. I never found enough time to test the read functionality.
If you get it done then that would be nice as I have some data that I
need to read from there.
 
   

Thanks,
Lucas
 
   

On Fri, Feb 19, 2010 at 4:07 PM, Jim Steilj...@qlf.comwrote:
 
   

These is definitely more one DB2 driver for the AS/400.  I seem to recall
seeing that there was working being done with one of them a couple years
ago, but don't recall which one.  And, I don't know the status.  Maybe a
better question would be...  Is there anyone else out there using SQLAlchemy
with DB2 on an AS/400?
   
   

 -Jim
   
   

On 2/19/2010 3:13 PM, Michael Bayer wrote:
   
   

On Feb 18, 2010, at 10:36 AM, Jim Steil wrote:
 
   

Hi
   
   

Just wondering if there is support for the IBM AS/400 database using
SQLAlchemy.
   
   

IBM produces a DB2 driver, dont know if that overlaps with AS/400
compatibility or not.
 
   

 -Jim
   
   

--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.
   
   

--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.
   

--
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.


 



   


--
Jim Steil
VP of Information Technology
Quality Liquid Feeds, Inc.
608.935.2345 office
608.341.9896 cell

--
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options,