[sqlalchemy] relation for single table, not joined

2010-02-19 Thread Kent
Suppose I have a database table, as an example, employee that has a
column dept, but the dept is not represented by any other table in
the database, it is just an attribute of employee.

I would like to be able to create a standalone relation on a class
that has no table so that I can assign lists to it and perform
session.merge() and other useful sqla operations as needed.

So, in that example, I would like to have a department object with a
relation of employees so that I could say:

empa = ...
empb = ...
empc = ...

department.dept = 'PAYROLL'
department.employees = [ empa, empb, empc ]

session.merge(department)

I don't really want a self-referential relation, I don't think,
because I don't want the table joined with itself; in fact, I don't
even want the table joined with anything at all.

Does sqla support this?  How could I accomplish this with no joins?

Thanks in advance.

-- 
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: relation for single table, not joined

2010-02-19 Thread Kent
In case the point wasn't clear, I'd like merge() to be able to figure
out which items to add, update and, esp, delete without needing to do
that programatically myself.


On Feb 19, 7:26 am, Kent k...@retailarchitects.com wrote:
 Suppose I have a database table, as an example, employee that has a
 column dept, but the dept is not represented by any other table in
 the database, it is just an attribute of employee.

 I would like to be able to create a standalone relation on a class
 that has no table so that I can assign lists to it and perform
 session.merge() and other useful sqla operations as needed.

 So, in that example, I would like to have a department object with a
 relation of employees so that I could say:

 empa = ...
 empb = ...
 empc = ...

 department.dept = 'PAYROLL'
 department.employees = [ empa, empb, empc ]

 session.merge(department)

 I don't really want a self-referential relation, I don't think,
 because I don't want the table joined with itself; in fact, I don't
 even want the table joined with anything at all.

 Does sqla support this?  How could I accomplish this with no joins?

 Thanks in advance.

-- 
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] relation for single table, not joined

2010-02-19 Thread Michael Bayer

On Feb 19, 2010, at 7:26 AM, Kent wrote:

 Suppose I have a database table, as an example, employee that has a
 column dept, but the dept is not represented by any other table in
 the database, it is just an attribute of employee.
 
 I would like to be able to create a standalone relation on a class
 that has no table so that I can assign lists to it and perform
 session.merge() and other useful sqla operations as needed.
 
 So, in that example, I would like to have a department object with a
 relation of employees so that I could say:
 
 empa = ...
 empb = ...
 empc = ...
 
 department.dept = 'PAYROLL'
 department.employees = [ empa, empb, empc ]
 
 session.merge(department)
 
 I don't really want a self-referential relation, I don't think,
 because I don't want the table joined with itself; in fact, I don't
 even want the table joined with anything at all.
 
 Does sqla support this?  How could I accomplish this with no joins?

how many tables are used in the example above ?  department and employee ?  
its clear what department here is if the table is employee with a column 
dept (and dept is a.string ?  array ?  comma separated ?)





 
 Thanks in advance.
 
 -- 
 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.



[sqlalchemy] Re: relation for single table, not joined

2010-02-19 Thread Kent
In my example, there is only *one* table, employee.  Yes, dept would
be a string column on employee.

The catch is there is *no* department table.

But I'd like to be able to call merge() given a list of employees for
a given dept and have it figure out which need to be added, updated
and deleted.

I think I could invent a department table, such as (using Oracle's
DUAL):

SELECT 'PAYROLL' FROM DUAL AS DEPT
UNION
SELECT 'DEVELOPMENT' FROM DUAL
UNION
SELECT 'ACCOUNTING' FROM DUAL
...


and then maybe I could create a mapper for the above view with a
relation to employee that JOINS the above view with the DEPT column on
employee.

I don't know if that would work, and even if it does, it's convoluted
and I didn't want to perform a JOIN for no reason.

Sorry if I am not communicating this well, but in the end I'd like to
do something like this:

(empa, empb, empc as all Employee objects, which is mapped to the
employee table):

empa = ...
empb = ...
empc = ...

department.dept = 'PAYROLL'
department.employees = [ empa, empb, empc ]

session.merge(department)




On Feb 19, 10:54 am, Michael Bayer mike...@zzzcomputing.com wrote:
 On Feb 19, 2010, at 7:26 AM, Kent wrote:



  Suppose I have a database table, as an example, employee that has a
  column dept, but the dept is not represented by any other table in
  the database, it is just an attribute of employee.

  I would like to be able to create a standalone relation on a class
  that has no table so that I can assign lists to it and perform
  session.merge() and other useful sqla operations as needed.

  So, in that example, I would like to have a department object with a
  relation of employees so that I could say:

  empa = ...
  empb = ...
  empc = ...

  department.dept = 'PAYROLL'
  department.employees = [ empa, empb, empc ]

  session.merge(department)

  I don't really want a self-referential relation, I don't think,
  because I don't want the table joined with itself; in fact, I don't
  even want the table joined with anything at all.

  Does sqla support this?  How could I accomplish this with no joins?

 how many tables are used in the example above ?  department and employee 
 ?  its clear what department here is if the table is employee with a 
 column dept (and dept is a.string ?  array ?  comma separated ?)



  Thanks in advance.

  --
  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 
  athttp://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.



[sqlalchemy] Generic ODBC connection (4D anyone?)

2010-02-19 Thread James
Anyone heard of 4D? Probably not, but I would love to work with
SQLAlchemy and this database.

How hard is it to write a new dialect?

Anyone had luck using generic odbc (ie not mysql moduled to pyodbc) to
connect to various unsupported databases?

I've tried a couple connection strings, the biggest problem is 4D
doesn't have a database name.

# connect to the actual database
from sqlalchemy import create_engine
#using DSN
engine = create_engine('mysql+pyodbc://4D_v11_Dev/DEFAULT_SCHEMA')
#using URL
engine = create_engine('mysql://user:p...@127.0.0.1', module='pyodbc')
#another dialect with DSN = ERROR: AttributeError: 'str' object has
no attribute 'paramstyle'
engine = create_engine('mssql://4D_v11_Dev', module='pyodbc')
# yet another try
engine = create_engine('mysql+pyodbc://4D_v11_Dev')
# show me output
engine.echo = True

None of those work, I have some stack traces, but the gist is this:
# when used without a database name
sqlalchemy.exc.DBAPIError: (Error) ('08004', '[08004] Server rejected
the connection:\nFailed to parse statement.\r (1301)
(SQLExecDirectW)') 'SELECT DATABASE()' ()

# when I try to specify a name
sqlalchemy.exc.DBAPIError: (Error) ('0', '[0] [iODBC][Driver
Manager]dlopen({MySQL}, 6): image not found (0) (SQLDriverConnectW)')
None None

But connection directly via pyodbc does work
import pyodbc
cnxn = pyodbc.connect(DSN=4D_v11_Dev;UID=user;PWD=pass)
cursor = cnxn.cursor()
cursor.execute('select * from ODBCTest')
a=cursor.fetchall()
print 'pyodbc',a

-- 
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] another problem with complex join

2010-02-19 Thread Michael Bayer

On Feb 18, 2010, at 11:55 AM, Manlio Perillo wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 Michael Bayer ha scritto:
 [...]
 so what I had in mind is that, if its given a join as the left side, 
 it just does the natural thing, i.e. joins to the right.
 If the natural join isn't available, then it does its usual
 search through the whole thing.
 
 What do you mean by natural join isn't available?
 There is no direct foreign key relationship between the left and the
 right side of the join?

yes.

 
 
 I think _match_primaries could, right before it raises its message,
 
 Since we are speaking about _match_primaries, I'm curious to know why
 the implementation is:
 
 def _match_primaries(self, primary, secondary):
global sql_util
if not sql_util:
from sqlalchemy.sql import util as sql_util
return sql_util.join_condition(primary, secondary)
 
 What is the need for a sql_util to be global?

that pattern is used when there is a circular module import between two 
modules.the global + boolean is to avoid repeated calls to import.

 
 just ask well is this particular foreign key the rightmost join on
 the left side and then its good.
 
 
 Non sure to understand what you have in mind, here.
 
 Do you mean that the checks:
 `if len(crit) == 0` and `len(constraints)  1` should not be done by the
 util.join_condition, and instead:
 
 1) `_match_primaries` method will call `util.join_condition`, using the
   rightmost join on the left side (as in my patch)
 2) if len(crit) == 0, then it will call `util.join_condition` again, but
   this time using the left side of the join, as is

that is pretty much what I mean.   if the left side is a join, then call 
join_condition with the rightmost side of the left first, if nothing returned, 
call with the full left side.



 
 ?
 
 
 to get non-default behavior, as always you'd specify the on clause.
 which you'd have to do anyway even without the natural feature if you
 wanted to joinunnaturally.
 
 
 Manlio
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.10 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
 
 iEYEARECAAYFAkt9cOYACgkQscQJ24LbaUSS7QCeMchE6p2t3WaHDJzH+dTAu2Xk
 BBUAmQHpDq8Naq9f4cWsolK9BRnjTBcf
 =UAU4
 -END PGP SIGNATURE-
 
 -- 
 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] Generic ODBC connection (4D anyone?)

2010-02-19 Thread Michael Bayer

On Feb 19, 2010, at 2:17 PM, James wrote:

 Anyone heard of 4D? Probably not, but I would love to work with
 SQLAlchemy and this database.
 
 How hard is it to write a new dialect?

by all reports, including some new ones gained today at pycon, it is extremely 
easy.  provided your database is relational.

 
 Anyone had luck using generic odbc (ie not mysql moduled to pyodbc) to
 connect to various unsupported databases?

step 1, get pyodbc to connect to your database.   that may be easy or may 
involve contacting the pyodbc author for fixes.

step 2, create a .py file that imports the PyODBC connector as a mixin to 
class YourDialect(), the same way as any other dialect, and make any changes 
to the create_connect_args method as necessary in your subclass.

step 3, establish a setup.py for your application which establishes your 
library as a setuptools entrypoint for sqlalchemy.dialects.   the name you 
give it is what you'd call upon in create_engine().  I'd suggest a name like 
4d+pyodbc.



 
 I've tried a couple connection strings, the biggest problem is 4D
 doesn't have a database name.
 
 # connect to the actual database
 from sqlalchemy import create_engine
 #using DSN
 engine = create_engine('mysql+pyodbc://4D_v11_Dev/DEFAULT_SCHEMA')
 #using URL
 engine = create_engine('mysql://user:p...@127.0.0.1', module='pyodbc')
 #another dialect with DSN = ERROR: AttributeError: 'str' object has
 no attribute 'paramstyle'
 engine = create_engine('mssql://4D_v11_Dev', module='pyodbc')
 # yet another try
 engine = create_engine('mysql+pyodbc://4D_v11_Dev')
 # show me output
 engine.echo = True
 
 None of those work, I have some stack traces, but the gist is this:
 # when used without a database name
 sqlalchemy.exc.DBAPIError: (Error) ('08004', '[08004] Server rejected
 the connection:\nFailed to parse statement.\r (1301)
 (SQLExecDirectW)') 'SELECT DATABASE()' ()
 
 # when I try to specify a name
 sqlalchemy.exc.DBAPIError: (Error) ('0', '[0] [iODBC][Driver
 Manager]dlopen({MySQL}, 6): image not found (0) (SQLDriverConnectW)')
 None None
 
 But connection directly via pyodbc does work
 import pyodbc
 cnxn = pyodbc.connect(DSN=4D_v11_Dev;UID=user;PWD=pass)
 cursor = cnxn.cursor()
 cursor.execute('select * from ODBCTest')
 a=cursor.fetchall()
 print 'pyodbc',a
 
 -- 
 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: relation for single table, not joined

2010-02-19 Thread Michael Bayer

On Feb 19, 2010, at 11:55 AM, Kent wrote:

 In my example, there is only *one* table, employee.  Yes, dept would
 be a string column on employee.
 
 The catch is there is *no* department table.


but what does this mean then ?

department.dept = 'PAYROLL'
department.employees = [ empa, empb, empc ]

empa, empb, empc are mapped to employee, correct ? what is department ? 
 is that also a row in employee ?or just a dummy object ?   if the 
latter, then no, merge() requires a mapped object as its argument, and you 
should create some kind of function that unwraps the ORM objects from your 
dummy department object and passes them to merge() with the desired state.

OTOH if the case here is, you'd like a string column on a mapped instance to 
spawn itself into some kind of object or collection, merge() has nothing to do 
with that, you'd implement that as a def on your class.


-- 
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] Support for IBM AS/400 database

2010-02-19 Thread Michael Bayer

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.



Re: [sqlalchemy] cursor description

2010-02-19 Thread Michael Bayer

On Feb 19, 2010, at 1:01 AM, anusha kadambala wrote:

 hello,
 
 I want to know how to find the cursor description i.e equivalent to 
 cursor.description in dbapi.I also want to know whether it is supported in 
 all types of databases?

result.cursor is the DBAPI cursor.  cursor.description can only be relied 
upon for column names, i.e. the first element of each tuple.  the second 
element, the type, is available to varying degrees depending on backend and 
specific query scenario.



 
 -- 
 
 
 Njoy the share of Freedom :)
 Anusha Kadambala
 
 -- 
 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.



[sqlalchemy] trouble with insert

2010-02-19 Thread daniel
Hello.

I'm having some trouble with inserting a new line into an existing
table. The table has 3 columns. Columns 1  2 are primary keys. I've
no trouble inserting into the table from scratch using one connection
- if I create the table  populate it in one session. But if the
connection is broken  I connect again using a different script I run
into trouble with inserting new rows.

Lets say i create a Table Object that references the table...

table = Table('TABLE', metadata, autoload = true, schema = 'SCHEMA')

The statement:

print table.insert() - prints all three fields in the compiled SQL
statement...

but the statement

print table.insert( values = {'column1': value1, 'column2':value2,
'column3':value3})

only gives me the fields that are primary keys - the third column is
dropped.

I realize i must be missing something but for the life of me I don't
know what it is... Any help would be greatly appreciated

Thanks in advance, d.

-- 
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] another problem with complex join

2010-02-19 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Michael Bayer ha scritto:
 [...]
 Since we are speaking about _match_primaries, I'm curious to know why
 the implementation is:
 
 def _match_primaries(self, primary, secondary):
global sql_util
if not sql_util:
from sqlalchemy.sql import util as sql_util
return sql_util.join_condition(primary, secondary)
 
 What is the need for a sql_util to be global?
 
 that pattern is used when there is a circular module import between two
 modules.the global + boolean is to avoid repeated calls to import.
 

Ok, thanks.
I have never seen this pattern in use.
If the import is done inside a function, usually there are no problems
with circular module import.


 
 just ask well is this particular foreign key the rightmost join on
 the left side and then its good.

 
 Non sure to understand what you have in mind, here.
 
 Do you mean that the checks:
 `if len(crit) == 0` and `len(constraints)  1` should not be done by the
 util.join_condition, and instead:
 
 1) `_match_primaries` method will call `util.join_condition`, using the
   rightmost join on the left side (as in my patch)
 2) if len(crit) == 0, then it will call `util.join_condition` again, but
   this time using the left side of the join, as is
 
 that is pretty much what I mean.   if the left side is a join, then call
 join_condition with the rightmost side of the left first, if nothing
 returned, call with the full left side.
 

Ok.
If no one else is interested in this feature I can try to write a patch,
with tests included.



Manlio
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkt/BoMACgkQscQJ24LbaURR6wCdEdo5mitZcabEArqPe2BQV1Ez
EY0An3YFxGgWE8LcHnHi6aqYlxoeKfPd
=+p49
-END PGP SIGNATURE-

-- 
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: relation for single table, not joined

2010-02-19 Thread Kent
I used department as a dummy type object, but I meant it to be an
illustration of what I am trying to accomplish.

I was hoping the illustration would spark a oh, I know what he's
trying to do... no, do it this way...

when merge() recurses to list relation, how does it build the list of
things to delete?

If it has already eagerly loaded this relation, it doesn't need to go
back to the database, correct?  Is it essentially looping through all
the items in the eagerly-loaded relation and if the merging copy
doesn't contain it, it moves it to the list of items to delete?

Thanks for you help, as always.


On Feb 19, 3:11 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 On Feb 19, 2010, at 11:55 AM, Kent wrote:

  In my example, there is only *one* table, employee.  Yes, dept would
  be a string column on employee.

  The catch is there is *no* department table.

 but what does this mean then ?

 department.dept = 'PAYROLL'
 department.employees = [ empa, empb, empc ]

 empa, empb, empc are mapped to employee, correct ?     what is department 
 ?  is that also a row in employee ?    or just a dummy object ?   if the 
 latter, then no, merge() requires a mapped object as its argument, and you 
 should create some kind of function that unwraps the ORM objects from your 
 dummy department object and passes them to merge() with the desired state.

 OTOH if the case here is, you'd like a string column on a mapped instance to 
 spawn itself into some kind of object or collection, merge() has nothing to 
 do with that, you'd implement that as a def on your class.

-- 
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] Support for IBM AS/400 database

2010-02-19 Thread Jim Steil
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.



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

2010-02-19 Thread Lukasz Szybalski
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 Steil j...@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.





-- 
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.



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

2010-02-19 Thread Jim Steil

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] another problem with complex join

2010-02-19 Thread Ben De Luca

 Ok, thanks.
 I have never seen this pattern in use.
 If the import is done inside a function, usually there are no problems
 with circular module import.

Its a performance gain as the second time you hit that function you don't have 
to import it again. 

-- 
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.