[sqlalchemy] Re: isolation level not supported on MySQL 3.23

2012-09-18 Thread Ids
Mmm. The traceback I got last (TypeError), only occurs on a client platform 
(redhat 8.0) using mysql 3.23 client software. When run on a platform with 
MySQL 5.0 (suse 10.1) software you're solution by raising the 
NotImplemented exception works.
redhat 8.0 + mysql 3.23 client + python-mysql 1.2.2 + sqlalchemy 0.7.8 + 
mysql server 3.23.31 (on other host) fails
suse 10.1 + mysql 5.0 client + python-mysql 1.2.2 + sqlalchemy 0.7.8 + 
mysql server 3.23.54 (on other host) works

Thanks 

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/RXAaI5QEo48J.
To post to this group, send email to sqlalchemy@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] isolation level not supported on MySQL 3.23

2012-09-17 Thread Ids
We were using SQLAlchemy 0.5.1 and wanted to upgrade to 0.7.8 but ran into 
the following problem.
When trying to create an engine, the mysql dialect tries to determine the 
current isolation level by issuing the SELECT @@tx_isolation; SQL statement 
(from dialects/mysql/base.py get_isolation_level()). However, this 
statement is not supported on MySQL 3.23 and therefore SQLAlchemy 0.7.8 
doesn't seem to work anymore.

We worked around this by not using SQLAlchemy anymore for our antique MySQL 
3.23 db, but this means you could also delete 3.23 from the supported 
database list. As a solution you could maybe add a try/except clause around 
it with a version check just like you do in do_commit() in 
dialects/mysql/base.py

Best regards,
Ids

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/uJQPXujgUCEJ.
To post to this group, send email to sqlalchemy@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: isolation level not supported on MySQL 3.23

2012-09-17 Thread Ids
We are using MySQL 3.23.31 on that machine :-) 
It seems tx_isolation was added ad 4.0.3 (according to 
http://dev.mysql.com/doc/refman/4.1/en/server-system-variables.html#sysvar_tx_isolation).
 
But if I add 
if self.server_version_info  (4, 0, 3):
  raise NotImplementedError()

I get another traceback:
Traceback (most recent call last):
  File ./t.py, line 9, in ?
con=engine.connect()
  File 
/opt/python-2.4/lib/python2.4/site-packages/sqlalchemy/engine/base.py, 
line 2472, in connect
return self._connection_cls(self, **kwargs)
  File 
/opt/python-2.4/lib/python2.4/site-packages/sqlalchemy/engine/base.py, 
line 878, in __init__
self.__connection = connection or engine.raw_connection()
  File 
/opt/python-2.4/lib/python2.4/site-packages/sqlalchemy/engine/base.py, 
line 2558, in raw_connection
return self.pool.unique_connection()
  File /opt/python-2.4/lib/python2.4/site-packages/sqlalchemy/pool.py, 
line 183, in unique_connection
return _ConnectionFairy(self).checkout()
  File /opt/python-2.4/lib/python2.4/site-packages/sqlalchemy/pool.py, 
line 387, in __init__
rec = self._connection_record = pool._do_get()
  File /opt/python-2.4/lib/python2.4/site-packages/sqlalchemy/pool.py, 
line 741, in _do_get
con = self._create_connection()
  File /opt/python-2.4/lib/python2.4/site-packages/sqlalchemy/pool.py, 
line 188, in _create_connection
return _ConnectionRecord(self)
  File /opt/python-2.4/lib/python2.4/site-packages/sqlalchemy/pool.py, 
line 273, in __init__
pool.dispatch.first_connect.exec_once(self.connection, self)
  File /opt/python-2.4/lib/python2.4/site-packages/sqlalchemy/event.py, 
line 282, in exec_once
self(*args, **kw)
  File /opt/python-2.4/lib/python2.4/site-packages/sqlalchemy/event.py, 
line 291, in __call__
fn(*args, **kw)
  File 
/opt/python-2.4/lib/python2.4/site-packages/sqlalchemy/engine/strategies.py, 
line 167, in first_connect
dialect.initialize(c)
  File 
/opt/python-2.4/lib/python2.4/site-packages/sqlalchemy/dialects/mysql/base.py,
 
line 2005, in initialize
self._detect_ansiquotes(connection)
  File 
/opt/python-2.4/lib/python2.4/site-packages/sqlalchemy/dialects/mysql/base.py,
 
line 2246, in _detect_ansiquotes
mode = row[1] or ''
  File 
/opt/python-2.4/lib/python2.4/site-packages/sqlalchemy/dialects/mysql/base.py,
 
line 2737, in __getitem__
item = self.rowproxy[index]
TypeError: unsubscriptable object

My test script is pretty simple.
...
url='%(driver)s://%(user)s:%(passwd)s@%(host)s/%(db)s' % cfg
engine=create_engine(url)
con=engine.connect()
con.close()

Thanks

Op maandag 17 september 2012 13:21:02 UTC+2 schreef Ids het volgende:

 We were using SQLAlchemy 0.5.1 and wanted to upgrade to 0.7.8 but ran into 
 the following problem.
 When trying to create an engine, the mysql dialect tries to determine the 
 current isolation level by issuing the SELECT @@tx_isolation; SQL statement 
 (from dialects/mysql/base.py get_isolation_level()). However, this 
 statement is not supported on MySQL 3.23 and therefore SQLAlchemy 0.7.8 
 doesn't seem to work anymore.

 We worked around this by not using SQLAlchemy anymore for our antique 
 MySQL 3.23 db, but this means you could also delete 3.23 from the supported 
 database list. As a solution you could maybe add a try/except clause around 
 it with a version check just like you do in do_commit() in 
 dialects/mysql/base.py

 Best regards,
 Ids


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/YfpYDdO8XCwJ.
To post to this group, send email to sqlalchemy@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] delete multiple objects

2009-02-20 Thread Ids

Hello,

I'm using the declarative extension and was wondering (after searching
the docs) how to elegantly delete multiple objects at once, preferably
without loading them in first. Suppose you've got a mapped class like
this:
class Person(Base):
  __tablename__ = 'persons'
  stamp = sa.Column(sa.DateTime)
 ...

Now you could delete multiple objects like this (I think):
Person.__table__.delete().where(stamp  somedate)

or like this with loading all objects:
persons = session.query(Person).filter(Person.stamp  somedate)
for person in persons:
  session.delete(person)

Is there something like session.delete(Person).filter(Person.stamp 
somedate) ?? i.e. something similar to the session.query construct but
instead of selecting performing a delete?

Regards,
Ids
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: set_shard problems

2008-11-28 Thread Ids

Excellent work! Indeed r5335 did fix the problem. Thank you very much
for your help.

Regards,
Ids

--~--~-~--~~~---~--~~
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: set_shard problems

2008-11-27 Thread Ids


Just tested with SQLAlchemy 0.4.8 and that one works fine (see log
below). So something relevant must have changed between 0.4.8 and
0.5.0rc1.

Regards,
Ids

2008-11-27 14:06:51,941 INFO sqlalchemy.orm.mapper.Mapper: (Person|
persons) _compile_property(id, Column)
2008-11-27 14:06:51,942 INFO sqlalchemy.orm.mapper.Mapper: (Person|
persons) _compile_property(name, Column)
2008-11-27 14:06:51,947 INFO sqlalchemy.orm.mapper.Mapper: (Person|
persons) Identified primary key columns: ColumnSet([Column('id',
Integer(), table=persons, primary_key=True, nullable=False)])
2008-11-27 14:06:51,947 INFO sqlalchemy.orm.mapper.Mapper: (Person|
persons) constructed
2008-11-27 14:06:52,047 INFO sqlalchemy.orm.mapper.Mapper: (Person|
persons) __initialize_properties() started
2008-11-27 14:06:52,051 INFO sqlalchemy.orm.mapper.Mapper: (Person|
persons) initialize prop id
2008-11-27 14:06:52,052 INFO sqlalchemy.orm.strategies.ColumnLoader:
register managed attribute id on class Person
2008-11-27 14:06:52,052 INFO sqlalchemy.orm.mapper.Mapper: (Person|
persons) initialize prop name
2008-11-27 14:06:52,049 INFO sqlalchemy.orm.strategies.ColumnLoader:
register managed attribute name on class Person
2008-11-27 14:06:52,049 INFO sqlalchemy.orm.mapper.Mapper: (Person|
persons) __initialize_properties() complete
2008-11-27 14:06:52,050 DEBUG root: QUERY 1: SELECT persons.id AS
persons_id, persons.name AS persons_name
FROM persons ORDER BY persons.id
 LIMIT 1
2008-11-27 14:06:52,078 INFO sqlalchemy.pool.QueuePool.0x..74: Created
new connection _mysql.connection open to 'localhost' at 829a20c
2008-11-27 14:06:52,078 INFO sqlalchemy.pool.QueuePool.0x..74:
Connection _mysql.connection open to 'localhost' at 829a20c checked
out from pool
2008-11-27 14:06:52,083 INFO sqlalchemy.engine.base.Engine.0x..94:
BEGIN
2008-11-27 14:06:52,084 INFO sqlalchemy.engine.base.Engine.0x..94:
SELECT persons.id AS persons_id, persons.name AS persons_name
FROM persons ORDER BY persons.id
 LIMIT 1
2008-11-27 14:06:52,081 INFO sqlalchemy.engine.base.Engine.0x..94: []
2008-11-27 14:06:52,086 DEBUG sqlalchemy.engine.base.Engine.0x..94:
Col ('persons_id', 'persons_name')
2008-11-27 14:06:52,087 DEBUG sqlalchemy.engine.base.Engine.0x..94:
Row (1L, 'bob')
2008-11-27 14:06:52,091 DEBUG sqlalchemy.orm.mapper.Mapper: (Person|
persons) _instance(): identity key (class '__main__.Person', (1L,),
None) not in session
2008-11-27 14:06:52,092 DEBUG sqlalchemy.orm.mapper.Mapper: (Person|
persons) _instance(): created new instance [EMAIL PROTECTED] identity
(class '__main__.Person', (1L,), None)
2008-11-27 14:06:52,092 DEBUG sqlalchemy.orm.strategies.ColumnLoader:
Returning active column fetcher for Mapper|Person|persons id
2008-11-27 14:06:52,089 DEBUG sqlalchemy.orm.strategies.ColumnLoader:
Returning active column fetcher for Mapper|Person|persons name
2008-11-27 14:06:52,089 DEBUG sqlalchemy.orm.strategies.ColumnLoader:
populating [EMAIL PROTECTED] with RowProxy/id
2008-11-27 14:06:52,090 DEBUG sqlalchemy.orm.strategies.ColumnLoader:
populating [EMAIL PROTECTED] with RowProxy/name
2008-11-27 14:06:52,095 DEBUG root: QUERY 1 RESULT: [__main__.Person
object at 0xb78aa60c]
2008-11-27 14:06:52,095 DEBUG root: QUERY 2: SELECT persons.id AS
persons_id, persons.name AS persons_name
FROM persons
 LIMIT 1

2008-11-27 14:06:52,096 INFO sqlalchemy.engine.base.Engine.0x..94:
SELECT persons.id AS persons_id, persons.name AS persons_name
FROM persons
 LIMIT 1

2008-11-27 14:06:52,094 INFO sqlalchemy.engine.base.Engine.0x..94: {}
2008-11-27 14:06:52,099 DEBUG sqlalchemy.engine.base.Engine.0x..94:
Col ('persons_id', 'persons_name')
2008-11-27 14:06:52,100 DEBUG sqlalchemy.engine.base.Engine.0x..94:
Row (1L, 'bob')
2008-11-27 14:06:52,100 DEBUG root: QUERY 2: RESULT: [(1L, 'bob')]

--~--~-~--~~~---~--~~
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] set_shard problems

2008-11-26 Thread Ids

Hello,

I think I have found a bug, but I may be doing something wrong. It
looks like session.query(class).set_shard(shard_id) does not work
and session.connection(shard_id=shard_id).execute does. The first
does not return any result, the second one does (even when executing
the same query).
I've tested it with MySQL 3.23.54 and 5.0.45 and sqlalchemy 0.5.0rc1,
rc2 and rc4.

Here is the test database setup:
CREATE TABLE persons (
id INTEGER NOT NULL AUTO_INCREMENT,
name VARCHAR(20) NOT NULL,
PRIMARY KEY (id),
UNIQUE (name)
);
insert into persons (name) values('bob');
insert into persons (name) values('alice');

Here is the test code:
#!/opt/python-2.4/bin/python
import sys
import logging

import sqlalchemy as sa
from sqlalchemy.orm.shard import ShardedSession
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base

logging.basicConfig(stream=sys.stdout, format='%(asctime)s %(levelname)
s %(name)s: %(message)s')
logging.getLogger('sqlalchemy').setLevel(logging.DEBUG)
logging.getLogger().setLevel(logging.DEBUG)

Session = sessionmaker(class_=ShardedSession)

Base = declarative_base()
class Person(Base):
  __tablename__ = 'persons'
  id = sa.Column(sa.Integer, primary_key=True)
  name = sa.Column(sa.String(20), unique=True, nullable=False)

  def __str__(self):
return 'Person(%s, %s)' % (self.id, self.name)

def shard_chooser(mapper, instance, clause=None):
  raise NotImplementedError

def id_chooser(query, ident):
  raise NotImplementedError

def query_chooser(query):
  raise NotImplementedError

Session.configure(shard_chooser=shard_chooser,
  id_chooser=id_chooser,
  query_chooser=query_chooser)

session = Session()
shard_id='test'
engine = sa.create_engine('mysql://[EMAIL PROTECTED]/%s' % shard_id)
session.bind_shard(shard_id, engine)

q = session.query(Person).set_shard(shard_id).limit(1)
logging.debug(QUERY 1: %s, q)
rows = list(q.all())
logging.debug(QUERY 1 RESULT: %s % rows)

#
# now to it manually:
#
q = '''SELECT persons.id AS persons_id, persons.name AS persons_name
FROM persons
 LIMIT 1
'''
logging.debug(QUERY 2: %s, q)
rows = session.connection(shard_id=shard_id).execute(q)
rows = list(rows)
logging.debug(QUERY 2: RESULT: %s % rows)

And here is the code output:
2008-11-26 10:52:26,043 INFO sqlalchemy.orm.strategies.ColumnLoader:
Person.id register managed attribute
2008-11-26 10:52:26,044 INFO sqlalchemy.orm.strategies.ColumnLoader:
Person.name register managed attribute
2008-11-26 10:52:26,045 DEBUG root: QUERY 1: SELECT persons.id AS
persons_id, persons.name AS persons_name
FROM persons
 LIMIT 1
2008-11-26 10:52:26,061 INFO sqlalchemy.pool.QueuePool.0x...8bf4:
Created new connection _mysql.connection open to 'localhost' at
82b02ec
2008-11-26 10:52:26,062 INFO sqlalchemy.pool.QueuePool.0x...8bf4:
Connection _mysql.connection open to 'localhost' at 82b02ec checked
out from pool
2008-11-26 10:52:26,062 INFO sqlalchemy.engine.base.Engine.0x...8a14:
BEGIN
2008-11-26 10:52:26,060 INFO sqlalchemy.engine.base.Engine.0x...8a14:
SELECT persons.id AS persons_id, persons.name AS persons_name
FROM persons
 LIMIT 1
2008-11-26 10:52:26,064 INFO sqlalchemy.engine.base.Engine.0x...8a14:
[]
2008-11-26 10:52:26,066 DEBUG sqlalchemy.engine.base.Engine.0x...8a14:
Col ('persons_id', 'persons_name')
2008-11-26 10:52:26,070 DEBUG root: QUERY 1 RESULT: []
2008-11-26 10:52:26,070 DEBUG root: QUERY 2: SELECT persons.id AS
persons_id, persons.name AS persons_name
FROM persons
 LIMIT 1

2008-11-26 10:52:26,071 INFO sqlalchemy.engine.base.Engine.0x...8a14:
SELECT persons.id AS persons_id, persons.name AS persons_name
FROM persons
 LIMIT 1

2008-11-26 10:52:26,071 INFO sqlalchemy.engine.base.Engine.0x...8a14:
{}
2008-11-26 10:52:26,073 DEBUG sqlalchemy.engine.base.Engine.0x...8a14:
Col ('persons_id', 'persons_name')
2008-11-26 10:52:26,073 DEBUG sqlalchemy.engine.base.Engine.0x...8a14:
Row (1L, 'bob')
2008-11-26 10:52:26,074 DEBUG root: QUERY 2: RESULT: [(1L, 'bob')]

There are two things I notice in the sqlalchemy.Engine logs; the
second SELECT statement seems to have an additional newline and the
next log (which seem to be the parameters for the select statement)
contain a {} instead of a [].

Am I doing something wrong here or is this supposed to work?

Regards,
Ids
--~--~-~--~~~---~--~~
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] Changing loglevels

2008-10-17 Thread Ids

Hi,

I'm using SQLA 0.5.0rc2 and am running into a problem. I've got a
piece of code like this:
import sys
import logging
import sqlalchemy as sa
from sqlalchemy.orm import sessionmaker

logging.basicConfig(stream=sys.stderr)
logging.getLogger('sqlalchemy.pool').setLevel(logging.ERROR)

engine = sa.create_engine(.)

logging.getLogger('sqlalchemy.pool').setLevel(logging.INFO)

In the example above I won't see any INFO log messages. However, if
you change the first setLevel from logging.ERROR to logging.INFO you
_do_ get INFO log messages. It looks like you have to specify a
loglevel below logging.WARN *before* creating the engine. Otherwise I
can't get any logging to work.

Maybe it's my lack of understanding the logging module, but does
someone know what is going on?

Regards,
Ids

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