[sqlalchemy] How do I do append_whereclause() using the ORM?

2006-12-18 Thread Robin Munn

Maybe this is in the documentation, but if so, I've missed it.

I'd like to do something like the stmt = users.select();
stmt.append_whereclause(...) example found in
http://www.sqlalchemy.org/docs/sqlconstruction.myt#sql_building , but
using a Query object taken from an ORM mapper via session.query(User).
Is this possible? How would I do it?

-- 
Robin Munn
[EMAIL PROTECTED]
GPG key 0x4543D577

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: how to assign values to columns of a mapper?

2006-12-16 Thread Robin Munn

On 12/16/06, robert rottermann [EMAIL PROTECTED] wrote:
 now I would like to do something like:
 data = readExcelsheet(xx)
 for newRec in data:
 for fname, fvalue in newRec.items():
mapper.c[fname] = fvalue
session.save(mapper)
 session.flush()

Each time through the loop, you're assigning new values to the columns
of the *same* object here. I think that may be what's causing your
problem. Try creating a new instance each time through the for newRec
in data: loop and see if the problem goes away.

-- 
Robin Munn
[EMAIL PROTECTED]
GPG key 0x4543D577

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: how to assign values to columns of a mapper?

2006-12-16 Thread Robin Munn

On 12/16/06, robert rottermann [EMAIL PROTECTED] wrote:
 more ideas ?
 robert

I've run out of ideas.

It might be better to show us snippets from the real code, rather than
the pseudocode. As it is, we're just guessing about what your code
looks like. And if the pseudocode you showed doesn't precisely
correspond to the real code (as with the creating a new mapper issue I
thought I'd spotted), that makes it even worse. I doubt anyone else
will be able to figure out your problem based on what you've given us
so far. (Although you never know, someone might surprise me).

-- 
Robin Munn
[EMAIL PROTECTED]
GPG key 0x4543D577

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: python ORM

2006-12-16 Thread Robin Munn

On 12/16/06, Michael Bayer [EMAIL PROTECTED] wrote:

 django was not available to the public until it was fully functional
 (youd go to the site and just get a coming soon-style splash
 page)..and even then it was already in production use in earlier forms.
  they knew that if you release something that wasnt polished and would
 lead to user frustration, people would get disinterested and leave.
 the strategy seems to have worked for them.

 its not your grandfather's open source community !

If you're responding to Ilias Lazaridis's comment, you should be aware
that he appears to be a troll. His post set off all my trolling post,
ignore sensors, plus I've seen him before. (Here, several months ago,
if I recall correctly). Incidentally,  there used to be a Wikipedia
article on him, which was recently deleted. But you can still see it
via Google's cache, at:

http://72.14.221.104/search?q=cache:HnC3ass1Y9YJ:en.wikipedia.org/wiki/Ilias_Lazaridis+ilias+lazaridishl=enct=clnkcd=1

I wasn't going to say anything unless someone responded to him, but in
the interests of pro-actively heading off a possible flamewar:

Please Don't Feed The Trolls. :-)

-- 
Robin Munn
[EMAIL PROTECTED]
GPG key 0x4543D577

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: in_() function help

2006-12-11 Thread Robin Munn

On 12/11/06, Jose Soares [EMAIL PROTECTED] wrote:

 Hi all,

 I need some help with in_ function

 (Pdb) print codice
 ['', '62714', '62601', '62602', '62612', '62614', '62603', '62610']
 (Pdb) print type(codice)
 type 'list'
 (Pdb) print select([Attivita.c.cod_specie],
 Attivita.c.codice.in_(tuple(codice)))
 SELECT attivita.cod_specie
 FROM attivita
 WHERE attivita.codice = %(attivita_codice)s

The in_() function expects to receive the list of values as multiple
parameters. If it receives only one parameter, it assumes that that
one parameter is a single value for the IN operation -- that is, you
said something like Attivita.c.codice.in_('62601').

So change that in_() call to Attivita.c.codice.in_(*tuple(codice))
(or even just Attivita.c.codice.in_(*codice) for simplicity's sake)
and you should get the expected results.

-- 
Robin Munn
[EMAIL PROTECTED]
GPG key 0x4543D577

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: in_() function help

2006-12-11 Thread Robin Munn

Date: Mon, 11 Dec 2006 13:28:25
From: Jose Soares [EMAIL PROTECTED]
To: sqlalchemy@googlegroups.com
Subject: [sqlalchemy] in_() function help

Date: Mon, 11 Dec 2006 13:27:58
From: Robin Munn [EMAIL PROTECTED]
To: sqlalchemy@googlegroups.com
Subject: Re: [sqlalchemy] in_() function help


Who needs the keys to the time machine next? I'm done using it now. :-)


-- 
Robin Munn
[EMAIL PROTECTED]
GPG key 0x4543D577

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: SQLAlchemy 0.3.2 released

2006-12-11 Thread Robin Munn

On 12/11/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 Mike yeah, still waiting for someone to show me some easy
 Mike non-commercial library that can create a decent PDF out of either
 Mike markdown, or HTML, or whatever...

 Why not load the HTML into a web browser, print it, but select Save as PDF
 instead of completing the print?  Are there distribution restrictions on
 such output?

Do you know a way to do that programmatically? Otherwise it would add
quite a bit of work to the usual docs release process, which Michael
has automated pretty successfully so far.

And even if there was a way to do that programmatically, it still
wouldn't look as good as the PDF output of a script specifically
designed to format Markdown (or HTML or whatever) into PDF.

-- 
Robin Munn
[EMAIL PROTECTED]
GPG key 0x4543D577

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: func.max()

2006-12-09 Thread Robin Munn

On 12/9/06, jose [EMAIL PROTECTED] wrote:

 Thank you Michael for your explanation.

 Since I can do (on sqlalchemy), the same thing in more than one ways,
 I'm very confused and I would like ask you, about
 Constructing SQL Queries via _table objects_ or _mapper classes_

 Seems to me that *table object* is more flexible than *classe*s to
 construct a query,
 but I wonder what the difference between those and when/why using one or
 another...

I'll try to explain.

 c = select(users)

With this method, what you get back when you call c.execute() is a
ResultProxy. You then would call result.fetchall() to get a list of
RowProxy objects, which you can then access in several ways:

row[0]   # Returns the value of the first column in the database table
row['name']   # Returns the value of the name column, regardless of
its position
row.address# Ditto for the address column

This is just like doing result = cursor.fetchall(); for row in
result: ... from any DBAPI module, except that the rows have some
slightly nicer ways to access them.

See http://www.sqlalchemy.org/docs/sqlconstruction.myt#sql_select_resultproxy
for more details about this usage.

 c = session.query(Users)

Using this approach, when you call c.select(), you'll get a list (not
a ResultProxy, but a plain old Python list) of User instances, each of
which has its attributes already filled-in and modifiable. Thus:

result = c.select_by(name='Robin')
u = result[0]
print u.name  # Prints Robin
u.name = 'Robin Munn'  # This marks the row as dirty
session.flush()  # This flushes all dirty rows, thus doing the
appropriate UPDATE statement

Notice how by simply setting the name attribute, I've caused an
UPDATE statement to be prepared. (It won't be actually *run* until you
call session.flush()). If you were using the c = select(users)
method of constructing SQL queries, you'd have needed to run the
UPDATE statement by hand, by doing:

update(users.c.name=='Robin').execute(name='Robin Munn')

(Or by doing connection.execute('UPDATE users SET name ...') and so
on. As with the SELECT statements, SQLAlchemy doesn't force you to use
its features. If you want to issue raw SQL, you can.)

The advantage of using SQLAlchemy's mapped objects, therefore, can be
seen in the fact that you didn't have to run the UPDATE statements
yourself. Nor did you have to keep track of which objects have been
changed (are dirty). SQLAlchemy does all that for you. By contrast,
when you use the bare c = select(users) approach (selecting against
the table object, not against the mapped class) then what you get are
plain old database rows, that do *not* track updates and so on --
which means you have to issue your UPDATE statements (and your INSERT
and DELETE statements) by hand.

http://www.sqlalchemy.org/docs/datamapping.myt#datamapping_query will
tell you more about issuing queries against mapped objects.

-- 
Robin Munn
[EMAIL PROTECTED]
GPG key 0x4543D577

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: SQL Alchemy

2006-12-08 Thread Robin Munn

On 12/4/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 Can you use real numbers and date into SQL Alchemy database?

In a word: yes. For real numbers, you'd use the Float() column type,
and for dates, you'd use the Date() column type. (Or the DateTime()
column type if you wanted both a date and time value).

http://www.sqlalchemy.org/docs/types.myt has a list of the basic data
types available, and an example of how to write your own types should
one of those not be sufficient.

http://www.sqlalchemy.org/docs/metadata.myt shows how to declare a table.

Hopefully this will answer your question.

-- 
Robin Munn
[EMAIL PROTECTED]
GPG key 0x4543D577

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: How to issue DDL statements?

2006-10-26 Thread Robin Munn

On 10/26/06, Christoph Zwerschke [EMAIL PROTECTED] wrote:
 I think the problem was that the whole chapter has the heading
 Constructing SQL *Queries* via Python Expressions
 Since an SQL *query* usually only means select statements, I had not
 suspected to find a solution for DDL in that chapter.

 Maybe you can find a better chapter title here,

Constructing SQL *Commands* via Python Expressions, perhaps? But
that might make some people think not queries. Maybe statements
instead of commands...

-- 
Robin Munn
[EMAIL PROTECTED]
GPG key 0xD6497014

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sqlalchemy
-~--~~~~--~~--~--~---



[sqlalchemy] Any chance of upgrading SQLAlchemy's SVN server to 1.4?

2006-10-25 Thread Robin Munn

Subversion 1.4 includes a nice new svnsync tool that can mirror a
repository much more efficiently than other tools like SVK. The only
catch is: it uses a new SVN protocol that was only introduced in 1.4,
so it can't talk to a version 1.3 or earlier server.

Since I'm behind a shared satellite-dish Internet connection, that's
moderately fast at night but dog-slow in the middle of the day (when
lots of businesses are trying to use it), I prefer to mirror the SVN
repositories of projects I'm interested in, updating the mirror every
night. That way if I want to contribute a patch, I can do a fast diff
against a local repository, instead of waiting five minutes for a
response to come back during Internet rush hour around here. (I wish
I was exaggerating -- but when you measure your typical ping times not
in milliseconds but in actual *seconds*, well, protocols that do a lot
of back-and-forth talking take quite a while to complete.)

Are there any plans to upgrade the SVN server that hosts SQLAlchemy to
Subversion 1.4? According to
http://subversion.tigris.org/svn_1.4_releasenotes.html, it doesn't
require a dump/reload -- but there's a new repository format
available, so that a dump/reload will provide performance gains in
both space and time.

And it would make my life quite a bit easier if I could use svnsync
instead of SVK. :-)

-- 
Robin Munn
[EMAIL PROTECTED]
GPG key 0xD6497014

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sqlalchemy
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Any chance of upgrading SQLAlchemy's SVN server to 1.4?

2006-10-25 Thread Robin Munn

P.S. While I was updating my SVK mirrors the other day, I noticed
something interesting. As of a few days ago SQLAlchemy now has more
revisions in its repository than SQLObject does. SQLAlchemy's at
revision 2065 as I write this, while SQLObject is at 2030.

This doesn't actually mean much, since both repositories do contain
other projects (zblog for SA, FormEncode and a few other projects for
SO), but it's a milestone of sorts. And it does reflect how incredibly
fast Michael seems to code.

Michael -- Thanks for all your hard work, and such a great, useful,
and even fun-to-use project!

-- 
Robin Munn
[EMAIL PROTECTED]
GPG key 0xD6497014

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sqlalchemy
-~--~~~~--~~--~--~---



[sqlalchemy] Re: echo and logging Turbogears and SQLAlchemy

2006-10-23 Thread Robin Munn

On 10/23/06, Karl Guertin [EMAIL PROTECTED] wrote:

 On 10/22/06, Jorge Vargas [EMAIL PROTECTED] wrote:
  is this statement correct?
  # set to 1 to make SQLAlchemy echo SQL commands on the console
  sqlalchemy.echo = 0

 I haven't looked at the code, but from experience I know that setting
 sqlalchemy.echo to anything but False in the config results in the sql
 statements getting echo'd.

0 would work too, of course, since it's a false value in Boolean
contexts. The code never checks for if echo == False, but always a
simple if echo: test, so 0, or an empty list, or any other false
value will work.

It's still better to use False than 0, though, because that makes it
plain that it's a boolean value.

-- 
Robin Munn
[EMAIL PROTECTED]
GPG key 0xD6497014

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sqlalchemy
-~--~~~~--~~--~--~---



[sqlalchemy] Anticipated changes in 0.3?

2006-10-19 Thread Robin Munn

It may be a little early to be asking this. But I'm going to be
teaching SQLAlchemy to about fifteen to twenty people in precisely
three weeks, and I'm preparing my lesson plan now. And I'm starting to
wonder whether my lesson plan (currently based on 0.2.8) will need
drastic tweaking, or minor tweaking, or no changes at all, when you
release 0.3. There were enough changes between 0.1 and 0.2 that a few
sections of my step-by-step tutorial needed a rewrite -- such as the
new create_engine() syntax, and passing a metadata object instead of
an engine object to the Table() constructor. (Incidentally, for anyone
who's interested, that tutorial is at
http://www.rmunn.com/sqlalchemy-tutorial/tutorial.html). Do you know
yet what changes you're planning to make in 0.3? At least, well enough
to give me a hint or two like I'm planning to completely overhaul the
ActiveMapper plugin or something like that?

-- 
Robin Munn
[EMAIL PROTECTED]
GPG key 0xD6497014

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sqlalchemy
-~--~~~~--~~--~--~---