[sqlalchemy] Re: sqlalchemy in virtualenv Instructions

2008-04-14 Thread Lukasz Szybalski
On Mon, Apr 14, 2008 at 11:30 AM, jason kirtland [EMAIL PROTECTED] wrote: Lukasz Szybalski wrote: Hello, Below you can find instructions on how to setup sqlalchemy in virtual environment. http://lucasmanual.com/mywiki/TurboGears#head-36fb4094da01b8c28e8bdca803c0f05774eb13b8

[sqlalchemy] Re: sqlalchemy in virtualenv Instructions

2008-04-14 Thread Lukasz Szybalski
On Mon, Apr 14, 2008 at 11:38 AM, jason kirtland [EMAIL PROTECTED] wrote: Lukasz Szybalski wrote: On Mon, Apr 14, 2008 at 11:30 AM, jason kirtland [EMAIL PROTECTED] wrote: Lukasz Szybalski wrote: Hello, Below you can find instructions on how to setup sqlalchemy in virtual

[sqlalchemy] Re: group_by, count, and name count field as ?

2008-04-11 Thread Lukasz Szybalski
Also what would be a syntax to make a same selection using session.query(th)? what would you like the ORM query to return ? Object instances ? currently, using group_by() and such with Query implies you're getting individual column tuples back using _values(), in which case its

[sqlalchemy] Re: group_by, count, and name count field as ?

2008-04-11 Thread Lukasz Szybalski
I.e., *all* columns from th are being added to the columns clause of the select. According to the SQL standard, these names all need to be added to the GROUP BY as well - if MS-SQL is allowing only a partial GROUP BY list, thats just poor behavior on the part of MS-SQL (MySQL has this

[sqlalchemy] Re: group_by, count, and name count field as ?

2008-04-11 Thread Lukasz Szybalski
ok, I don't think we are on a same page. So let me explain what I want and maybe unconfused myself on what is a proper way to get data out of database via sqlalchemy orm style. Query class should not be confused with the Select class, which defines database SELECT operations at the SQL

[sqlalchemy] Re: group_by, count, and name count field as ?

2008-04-11 Thread Lukasz Szybalski
Above statements should result in query like: 'select a,count(a) from x where b=5,c=6 group by a' In order to get ORM object I need to use query. (That is what I get from reading the sentence I quoted) From the above, what ORM object would you like ? the one which has a as

[sqlalchemy] group_by, count, and name count field as ?

2008-04-10 Thread Lukasz Szybalski
Hello, I am trying to do a simple query which gets id, count(*) group by id, s=sqlalchemy.select([th.RECORD_NO,sqlalchemy.func.count(th.RECORD_NO)],sqlalchemy.and_(th.APPLIED_TEST==1,th.CODING_DATE=='20080404')).group_by(th.RECORD_NO).execute() This produces: SELECT [].[RECORD_NO],

[sqlalchemy] Re: mssql, Linux, unixODBC - Could not locate column in row for column

2008-04-02 Thread Lukasz Szybalski
On Wed, Apr 2, 2008 at 6:22 PM, Rick Morrison [EMAIL PROTECTED] wrote: also of concern is that, nobodys ever going to know they need to use this parameter when this issue arises. Well the idea is that this is a workaround for what I suspect is a broken Unix + pyodbc configuration, not a

[sqlalchemy] Re: mssql, Linux, unixODBC - Could not locate column in row for column

2008-04-02 Thread Lukasz Szybalski
On Wed, Apr 2, 2008 at 6:35 PM, Rick Morrison [EMAIL PROTECTED] wrote: So how would I find out if this is pyodbc or unixodbc? On Unix, it's both. pyodbc is the Python DB-API module that provides the DB-API2 interface for sqlalchemy it in turn relies on an underlying ODBC layer. unixodbc

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-04-01 Thread Lukasz Szybalski
On Mon, Mar 31, 2008 at 4:57 PM, Rick Morrison [EMAIL PROTECTED] wrote: You are correct: Port= fixes it. If you guys could fix this in svn, and point me to some instructions on how to install sqlalchemy in virtual / home directory that would be great. OK, great,

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-04-01 Thread Lukasz Szybalski
On Tue, Apr 1, 2008 at 9:26 AM, Rick Morrison [EMAIL PROTECTED] wrote: or sqlalchemy connection string will have to provide some way to add a driver name to connection string. sqlalchemy.create_engine('mssql://user:[EMAIL PROTECTED]:1433/?driver=TDS') That capability, with that

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-04-01 Thread Lukasz Szybalski
On Tue, Apr 1, 2008 at 10:09 AM, Lukasz Szybalski [EMAIL PROTECTED] wrote: On Tue, Apr 1, 2008 at 9:26 AM, Rick Morrison [EMAIL PROTECTED] wrote: or sqlalchemy connection string will have to provide some way to add a driver name to connection string

[sqlalchemy] sqlalchemy in virtualenv

2008-04-01 Thread Lukasz Szybalski
Hello, I am trying to use sqlalchemy from svn. I have checkout the code in /home/lucas/tmp/sqlalchemy I installed python-virtualenv I created my virtualenv python /usr/lib/python2.4/site-packages/virtualenv.py ENV I install sqlalchemy export

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-31 Thread Lukasz Szybalski
On Sat, Mar 29, 2008 at 10:50 PM, Randall Smith [EMAIL PROTECTED] wrote: Paul Johnston wrote: Hi, eng = sqlalchemy.create_engine(mssql:///?dsn=mydsn,UID=myusername,PWD=mypass,module=pyodbc) Try this: eng =

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-31 Thread Lukasz Szybalski
On Mon, Mar 31, 2008 at 9:53 AM, Rick Morrison [EMAIL PROTECTED] wrote: So what you are saying here is that sqlalchemy will figure out what driver to use? pyodbc or other? Sort of. Attempts are made to import appropriate modules until one doesn't fail. The order is: [pyodbc, mssql,

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-31 Thread Lukasz Szybalski
On Mon, Mar 31, 2008 at 12:21 PM, Rick Morrison [EMAIL PROTECTED] wrote: It looks to me as if you have unixodbc installed, but don't have a SQL Server driver installed, or it's named differently. Unixodbc drivers are here: http://www.unixodbc.org/drivers.html I'm not really up on my

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-31 Thread Lukasz Szybalski
On Mon, Mar 31, 2008 at 2:07 PM, Rick Morrison [EMAIL PROTECTED] wrote: You didn't say how am I supposed to use it in create engine? http://www.sqlalchemy.org/docs/04/dbengine.html#dbengine_options Anyway. I went into sqlalchemy/databases/mssql.py changed the line 791 to:

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-31 Thread Lukasz Szybalski
On Mon, Mar 31, 2008 at 3:50 PM, Rick Morrison [EMAIL PROTECTED] wrote: I think I remember a Port= in the ODBC connection string. ...would you please try this format on line 816: connectors.append('Server=%s;Port=%d' % (keys.get('host'), keys.get('port'))) You are correct: Port= fixes it.

[sqlalchemy] Re: Strange caching problem with Apache

2008-03-29 Thread Lukasz Szybalski
On Fri, Mar 28, 2008 at 10:54 PM, Graham Dumpleton [EMAIL PROTECTED] wrote: On Mar 29, 11:02 am, Michael Bayer [EMAIL PROTECTED] wrote: On Mar 28, 2008, at 7:56 PM, john spurling wrote: I added debugging to get id(session) and len(list(session)). The session id is unique every

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-25 Thread Lukasz Szybalski
On Tue, Mar 25, 2008 at 9:21 AM, Paul Johnston [EMAIL PROTECTED] wrote: Hi, eng = sqlalchemy.create_engine(mssql:///?dsn=mydsn,UID=myusername,PWD=mypass,module=pyodbc) Try this: eng = sqlalchemy.create_engine(mssql://myusername:mypass@/?dsn=mydsn,module=pyodbc) Still the same

[sqlalchemy] sqlachemy, mod_wsgi, and apache2

2008-03-03 Thread Lukasz Szybalski
What is the proper connection string for sqlalchemy to support pool_recycle? Is there a setting in mod_Wsgi to support this? sqlachemy.dburi=mysql://username:[EMAIL PROTECTED]:3306/databasename ?? I found the following :

[sqlalchemy] Re: sqlachemy, mod_wsgi, and apache2

2008-03-03 Thread Lukasz Szybalski
On Mon, Mar 3, 2008 at 8:26 PM, Michael Bayer [EMAIL PROTECTED] wrote: On Mar 3, 2008, at 9:17 PM, Lukasz Szybalski wrote: What is the proper connection string for sqlalchemy to support pool_recycle? Is there a setting in mod_Wsgi to support this? its a create_engine option, so

[sqlalchemy] Re: msqsql and sqlalchemy on linux -was Re: mssql connection uri

2008-01-25 Thread Lukasz Szybalski
On Jan 17, 2008 3:27 PM, Rick Morrison [EMAIL PROTECTED] wrote: Adodbapi is Windows-only, you're definitely barking up the wrong tree with that one. Pyodbc on Linux is theoretically possible, but I know of no users and have very little experience myself with it. Pymssql is supported on

[sqlalchemy] ceODBC support in sqlalchemy?

2008-01-17 Thread Lukasz Szybalski
I was able to connect to mssql vi ceODBC driver on linux using unixODBC. How hard would it be to support ceODBC in sqlalchemy? -- Instructions to setup dsn on unix: http://lucasmanual.com/mywiki/TurboGears#head-bab4c0bbfb83fb7c376a8a0cb68841c4e76ad130 apt-get install python-dev apt-get

[sqlalchemy] msqsql and sqlalchemy on linux -was Re: mssql connection uri

2008-01-17 Thread Lukasz Szybalski
On Jan 14, 2008 3:21 PM, Rick Morrison [EMAIL PROTECTED] wrote: The mssql URI is going to take the same conceptual form as any other sqlalchemry dburi. The format is documented and available in the SA docs. We can't give you the exact URI, because it's going to contain things that are

[sqlalchemy] mssql connection uri

2008-01-14 Thread Lukasz Szybalski
Hello, I need to extend my turbogears app to get some records from ms sql. Do you guys know how to setup the ms sql dbi uri to work with sqlalchemy? What connection uri do I use? How do I setup unix odbc for it? Anything else I need? Can you give me exact instructions? Thanks, Lucas --

[sqlalchemy] compoundprimary key

2007-12-21 Thread Lukasz Szybalski
Hello, What is the code for setting up a compound key? For normal key I would do: Column('id', Integer, primary_key=True, autoincrement), For compound key I do? Column('id', Integer, primary_key=True), Column('idupdate', Integer, primary_key=True, autoincrement), In sql form that would be

[sqlalchemy] assign_mapper and order_by?

2007-11-01 Thread Lukasz Szybalski
Hello, Does assign_mapper have any order_by function available to him after the object has been mapped? model.py - myclass_table = sqlalchemy.Table('myClass', metadata, autoload=True) class myClass(object): pass myclassmapper=assign_mapper(session.context,myClass,myclass_table)

[sqlalchemy] Re: Looking for feedback on encapsulating SA logic (newbie)

2007-10-30 Thread Lukasz Szybalski
Is this a turbogears app? or just your stand alone app? On 10/28/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I just started experimenting with .4 last night, and I'm really jazzed. The tutorials have been helpful, but I'm struggling to figure out how to bridge the gap between the

[sqlalchemy] sort results by date

2007-10-30 Thread Lukasz Szybalski
Hello, I am trying to make a select statement which involves date sorting. x1=model.User.select(model.User.c.ZIPCODE==zipcode ) now I get a list of 3 records x1[0],x1[1],x1[2] How can I sort x1 by x[0].c.DATE ?? ASC ? What would python code for that look like? or how could I change this to

[sqlalchemy] Re: SQLalchemy coding style

2007-10-30 Thread Lukasz Szybalski
On 10/30/07, McA [EMAIL PROTECTED] wrote: Hi all, thank you for your comments. I really expected to get comments from more people. But probably I'm concerned about something you don't have to. ;-) So, I'll wait. it seems better to use: import sqlalchemy and in code do:

[sqlalchemy] turbogears, sqlalchemy and utf8

2007-10-23 Thread Lukasz Szybalski
Hello, I came across this errors when I was working with unicode mysql database. My record would not get displayed and I would get: UnicodeDecodeError: 'utf8' codec can't decode byte 0xbf in position 261: unexpected code byte I was referred to

[sqlalchemy] Re: turbogears, sqlalchemy and utf8

2007-10-23 Thread Lukasz Szybalski
On 10/23/07, Marco Mariani [EMAIL PROTECTED] wrote: Lukasz Szybalski wrote: dev.cfg has sqlalchemy.dburi=mysql://user:[EMAIL PROTECTED]:3306/dbname I did this in dev.cfg : sqlalchemy.convert_unicode = True sqlalchemy.dburi=mysql://user:[EMAIL PROTECTED]:3306/dbname now I get

[sqlalchemy] Re: multiple inserts of sqlalchemy instances?

2007-10-23 Thread Lukasz Szybalski
: Lukasz Szybalski [EMAIL PROTECTED] To: sqlalchemy@googlegroups.com Sent: Monday, October 22, 2007 3:54:03 PM Subject: [sqlalchemy] multiple inserts of sqlalchemy instances? Hello, I need to save data multiple times in a for loop. I was trying to do something like this: You are able to select

[sqlalchemy] Re: multiple inserts of sqlalchemy instances?

2007-10-23 Thread Lukasz Szybalski
On 10/23/07, Michael Bayer [EMAIL PROTECTED] wrote: On Oct 23, 2007, at 10:16 AM, Lukasz Szybalski wrote: I am having an issue with a second new.flush() Does this require multiple sessions for each save? I can't find any documentation on multiple inserts with assign_mapper. Lucas

[sqlalchemy] Re: case inconsistency in reflected column names between mac and windows

2007-10-23 Thread Lukasz Szybalski
On 10/23/07, Travis Kriplean [EMAIL PROTECTED] wrote: It appears that this only occurs on macs running a ppc processor, not an intel processor. I run into the same problem when I transfer mysql data over to Linux. Windows mysql is case insensitive while linux version cares what case it is.

[sqlalchemy] multiple inserts of sqlalchemy instances?

2007-10-22 Thread Lukasz Szybalski
Hello, I need to save data multiple times in a for loop. I was trying to do something like this: You are able to select which group you want to be in: A,B,C,D for record in userchoice: new=model.User() #set some variables if record.group=='A': #set some more fields

[sqlalchemy] Re: TurboGears: best practices for SELECTing

2007-10-10 Thread Lukasz Szybalski
On 10/10/07, James Brady [EMAIL PROTECTED] wrote: Hello all, I'm a newcomer to SA, using it as the ORM for TurboGears at the moment. Is there documentation/tutorials/recipes somewhere about how to properly use SA from TurboGears? The problem I'm hitting at the moment is how to properly

[sqlalchemy] How to get ID back from database after save?

2007-09-11 Thread Lukasz Szybalski
Hello, I am saving to my column in this way. How do I get the primary key id back from database? z=User() z.LASTNAME='smith' z.FIRSTNAME='joe' z.save_or_update() z.flush() How do I get my z.USER_SID which is my primary auto increment key in database. Lucas

[sqlalchemy] Re: sqlalchemy with turbogears and assign_mapper: group_by

2007-09-11 Thread Lukasz Szybalski
On 9/10/07, Roger Demetrescu [EMAIL PROTECTED] wrote: On 9/8/07, Lukasz Szybalski [EMAIL PROTECTED] wrote: On 9/7/07, Paul Johnston [EMAIL PROTECTED] wrote: Hi, And if I wanted to select a year and group by year? select User.Year from User group by User.Year db.execute

[sqlalchemy] Re: sqlalchemy with turbogears and assign_mapper: group_by

2007-09-11 Thread Lukasz Szybalski
Hi, And if I wanted to select a year and group by year? select User.Year from User group by User.Year db.execute(select([User.Year]) ??? Have a look at http://www.sqlalchemy.org/docs/04/sqlexpression.html Ok. Based on documentation. I do: import

[sqlalchemy] Re: sqlalchemy with turbogears and assign_mapper: group_by

2007-09-11 Thread Lukasz Szybalski
On 9/11/07, Lukasz Szybalski [EMAIL PROTECTED] wrote: Hi, And if I wanted to select a year and group by year? select User.Year from User group by User.Year db.execute(select([User.Year]) ??? Have a look at http://www.sqlalchemy.org/docs/04

[sqlalchemy] getattr(myresults,ColumName) vs myresults[ColumnName]

2007-09-11 Thread Lukasz Szybalski
Hello, Are there any plans to make the attributes of selected results more dictionary like? Currently when you get a record via sqlalachemy You have an option of Getting and setting attributes by getattr and setattr. myresults.c.keys() then to get the values you have to: for column in

[sqlalchemy] Re: sqlalchemy.select() and tablename.select() why are they different?

2007-09-07 Thread Lukasz Szybalski
On 9/6/07, Lukasz Szybalski [EMAIL PROTECTED] wrote: On 9/6/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Thursday 06 September 2007 23:03:35 Lukasz Szybalski wrote: Hello, So it seems to me there are two select function that I can use but they are different First: s

[sqlalchemy] Re: sqlalchemy.select() and tablename.select() why are they different?

2007-09-07 Thread Lukasz Szybalski
ok. So this time I am trying to get data from my widget from database that has two compound keys, using assign_mapper. #Initialize: User_table = sqlalchemy.Table('User', metadata, autoload=True) class User(object): pass usermapper=assign_mapper(session.context,User,user_table) #get

[sqlalchemy] sqlalchemy.select() and tablename.select() why are they different?

2007-09-06 Thread Lukasz Szybalski
Hello, So it seems to me there are two select function that I can use but they are different First: s=Users.select(Users.c.LASTNAME=='Smith') but when you want to select only two columns via : s=Users.select([Users.c.LASTNAME, Users.c.FIRSTNAME], Users.c.LASTNAME =='Smith') you get an error :

[sqlalchemy] Re: sqlalchemy.select() and tablename.select() why are they different?

2007-09-06 Thread Lukasz Szybalski
On 9/6/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Thursday 06 September 2007 23:03:35 Lukasz Szybalski wrote: Hello, So it seems to me there are two select function that I can use but they are different First: s=Users.select(Users.c.LASTNAME=='Smith') but when you want

[sqlalchemy] Re: sqlalchemy with turbogears and assign_mapper: select

2007-09-05 Thread Lukasz Szybalski
Hello, I am using turbogears with sqlalchemy and assign_mapper. How do I select one column only when doing a select statement? d=model.Useraddress() How do I do: select Address_Sid from Useraddress where User_Sid='30' This d.select_by(USER_SID=30) will do select * from Useraddress where

[sqlalchemy] Re: sqlalchemy with turbogears and assign_mapper: select

2007-09-05 Thread Lukasz Szybalski
Hi, I am using turbogears with sqlalchemy and assign_mapper. How do I select one column only when doing a select statement? Can I ask why you want to do that? Unless you're really speed critical, selecting them all isn't too bad. But, if you're set on this, there are two approaches:

[sqlalchemy] Re: sqlalchemy with turbogears and mapper-part3 relation and flow control

2007-08-27 Thread Lukasz Szybalski
Hello, ok so I got the connection, select statements working using turbogears, assign_mapper and sqlalchemy. Now i need to work out the relation. User has a one to many relation with address, email, accounts. In reverse: address, email and accounts have many to one... #here is my table

[sqlalchemy] Re: sqlalchemy with turbogears and mapper-part2 connect and select

2007-08-17 Thread Lukasz Szybalski
hello - you generally use mapper() and relation() to set up how you'd like your classes to correspond to your table relationships. as far as compound keys, if they are defined with a primary key constraint you shouldn't have to worry about them. --- Ok. So we are using mapper()

[sqlalchemy] Re: sqlalchemy with turbogears and mapper-part2 connect and select

2007-08-17 Thread Lukasz Szybalski
ok...correct me if I'm wrong. #we start by importing from turbogears.database import metadata, session,bind_meta_data from sqlalchemy.ext.assignmapper import assign_mapper from turbogears import widgets, validators import sqlalchemy #Then we bound to database bind_meta_data() #create a table

[sqlalchemy] sqlalchemy with turbogears and mapper

2007-08-16 Thread Lukasz Szybalski
Hello, I am setting up a website with existing database using turbogears. Database is in mysql. I am using sqlalchemy but I'm having problems with choosing the mapper? There is around 20 tables with a lot of foreign key, compound keys and alternative keys. Which mapper do I use? Can you point

<    1   2