[sqlalchemy] Re: SQL echoing?

2007-02-13 Thread saxon75

I traced through the source a little and it appears that line 309 in
orm/strategies.py is what's causing these lines to be printed.
Looking through the repository, I see it's been corrected as of
r2255.  (I was using r2251).



On Feb 11, 9:20 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 something is setting echo=True somewhere or using Python's logging
 module and turning on SA logging.  see the docs/FAQ with regards to
 SA's usage of logging.

 On Feb 9, 11:42 am, saxon75 [EMAIL PROTECTED] wrote:

  settings.db_string = 'mysql://user:[EMAIL PROTECTED]/db'

  I'm using MySQL 4.1.14-Debian_5-log and the specific database uses the
  MyISAM engine.


--~--~-~--~~~---~--~~
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: Problem working with MySQL

2007-01-24 Thread saxon75

Here's what I get:

mysql show variables like 'lower_case_table_names';

++---+
| Variable_name  | Value |
++---+
| lower_case_table_names | 0 |
++---+


--~--~-~--~~~---~--~~
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: Problem working with MySQL

2007-01-24 Thread saxon75

 from sqlalchemy import *
 engine = create_engine('mysql://my database')
 connection = engine.connect()
 print connection.execute(show variables like 
 'lower_case_table_names').fetchone()

('lower_case_table_names', array('c', '0'))


--~--~-~--~~~---~--~~
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: Problem working with MySQL

2007-01-24 Thread saxon75

That did it.  Thanks!


--~--~-~--~~~---~--~~
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: MySQL Functions

2006-12-21 Thread saxon75


It must be something stupid on my end, then.  I'm sure I'll smack
myself when I figure it out.

Thanks for your help.

On Dec 20, 6:24 pm, Michael Bayer [EMAIL PROTECTED] wrote:

i just tried out your example and it executes fine using mysql 5, query
output is:

SELECT blog_articles.timestamp AS blog_articles_timestamp,
blog_articles.text AS blog_articles_text, blog_articles.id AS
blog_articles_id, blog_articles.title AS blog_articles_title
FROM blog_articles
WHERE year(from_unixtime(blog_articles.timestamp)) = %s ORDER BY
blog_articles.id

params: ['2006']



--~--~-~--~~~---~--~~
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] MySQL Functions

2006-12-20 Thread saxon75


Hi there,

I'm looking for a little help using MySQL functions in a WHERE clause
with SQLAlchemy.

The query I'd like to do is something like SELECT * FROM x WHERE
YEAR(FROM_UNIXTIME(timestamp)) == '2006';

Here's how I've tried to implement it:

metadata = MetaData()

articles_table = Table('blog_articles', metadata,
   Column('id', Integer, primary_key = True),
   Column('timestamp', Integer),
   Column('section_id', Integer, ForeignKey('blog_sections.id')),
   Column('title', String(255)),
   Column('text', TEXT)
)

class Article(object):
 def __init__(self, timestamp, title, text):
   self.article_timestamp = timestamp
   self.article_title = title
   self.article_text = text

mapper(Article, articles_table)

db = create_engine(settings.db_string)
session = create_session(bind_to=db)

result =
session.query(Article).select(func.year(func.from_unixtime(Article.c.timestamp))=='2006')

This throws the following error:
(ProgrammingError) function from_unixtime(integer) does not exist
HINT:   No function matches the given name and argument types. You may
need to add explicit type casts.

I tried a few things to explicitly cast the row type, but nothing
seemed to work.

This:
session.query(Article).select(func.year(func.from_unixtime(cast(Article.c.timestamp,
DateTime)))=='2006')

threw the following error:
(ProgrammingError) cannot cast type integer to timestamp with time
zone)

Any suggestions?

Thanks.


--~--~-~--~~~---~--~~
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: MySQL Functions

2006-12-20 Thread saxon75


The initial query I posted definitely works--I've been using something
very much like it for a long time in my existing application.  I've
only recently discovered SA, though, and I'm trying to incorporate it
into my design.  FROM_TIMESTAMP can definitely take an integer input.

Anyway, thanks.


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