[sqlalchemy] Re: date format
On Thu, 2007-01-02 at 07:53 +0100, jose wrote: Thank you Guy to answer my question. I know I can use the strftime property of datetime to format my dates as: qry.data_inizio.strftime('%d/%m/%Y') but what I'm looking for, is a way to setting date style in SA or psycopg2 whithout need to apply functions to change the default format. Is it possible? You can change the date format returned by Postgres. http://www.postgresql.org/docs/8.0/interactive/functions-formatting.html So I expect it would be awkward to put this into SA or psychopg2, which is why I suggested python. -- --gh --~--~-~--~~~---~--~~ 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: Tool to check whether DB matches model
Hi, Well, I see a model as a set of tables. In this particular case, a model is the set of tables created with a particular MetaData object. I guess model is a term from the MVC world, so perhaps there's a better term for SA users. Paul On 1/30/07, Michael Bayer [EMAIL PROTECTED] wrote: what i cant see here is exactly what a model is. if its a TG thing, then this app would belong with Turbogears. --~--~-~--~~~---~--~~ 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] r2285 breaks some lazy loading
Here last version of the all*AB testcase. 2284 is ok. 2285 - no. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~--- testABall.tbz Description: application/tbz
[sqlalchemy] about cascade rule
Hi. I still do not fully understand cascade rules, however I want to be sure the behaviour below is a feature and not a bug. Here is the code: from sqlalchemy import * db = create_engine('postgres://manlio:[EMAIL PROTECTED]/test', echo=False) metadata = BoundMetaData(db) a = Table( 'a', metadata, Column('id', Integer, primary_key=True), Column('x', String) ) b = Table( 'b', metadata, Column('uid', String, primary_key=True), Column('id', Integer, ForeignKey(a.c.id)), Column('y', String) ) class A(object): def __init__(self, x): self.x = x class B(object): def __init__(self, id, y): self.id = id self.y = y aMapper = mapper(A, a) bMapper = mapper( B, b, properties={ 'a': relation( A, lazy=False, cascade='all, delete-orphan' ) } ) try: metadata.create_all() conn = db.connect() trans = conn.begin() sess = create_session(bind_to=conn) obj = A('x') sess.save(obj) sess.flush() sess.close() trans.commit() conn.close() finally: metadata.drop_all() When executing this script I obtain: Traceback (most recent call last): File cascade.py, line 52, in ? sess.flush() File /usr/lib/python2.4/site-packages/sqlalchemy/orm/session.py, line 220, in flush self.uow.flush(self, objects) File /usr/lib/python2.4/site-packages/sqlalchemy/orm/unitofwork.py, line 175, in flush if object_mapper(obj)._is_orphan(obj): File /usr/lib/python2.4/site-packages/sqlalchemy/orm/mapper.py, line 232, in _is_orphan raise exceptions.FlushError(instance %s is an unsaved, pending instance and is an orphan (is not attached to %s) % sqlalchemy.exceptions.FlushError: instance __main__.A object at 0xb79d946c is an unsaved, pending instance and is an orphan (is not attached to any parent 'B' instance via that classes' 'a' attribute) [EMAIL PROTECTED]:~/projects/bugs/sqlalchemy$ python cascade.py Traceback (most recent call last): File cascade.py, line 52, in ? sess.flush() File /usr/lib/python2.4/site-packages/sqlalchemy/orm/session.py, line 220, in flush self.uow.flush(self, objects) File /usr/lib/python2.4/site-packages/sqlalchemy/orm/unitofwork.py, line 175, in flush if object_mapper(obj)._is_orphan(obj): File /usr/lib/python2.4/site-packages/sqlalchemy/orm/mapper.py, line 232, in _is_orphan raise exceptions.FlushError(instance %s is an unsaved, pending instance and is an orphan (is not attached to %s) % sqlalchemy.exceptions.FlushError: instance __main__.A object at 0xb79a146c is an unsaved, pending instance and is an orphan (is not attached to any parent 'B' instance via that classes' 'a' attribute) Thanks and regards Manlio Perillo --~--~-~--~~~---~--~~ 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] MapperExtension with options
I wanted to experiment with using a MapperExtension to add a couple of non-mapped properties to a class at load time. def MyExt(MapperExtension): def populate_instance(self, mapper, selectioncontext, row, instance, identitykey, isnew): print Hello World # do some work here return EXT_PASS obj=query(MyObj).options(extension(MyExt)).select() MyExt isn't printing anything though.. Am I missing something? Thanks Dennis --~--~-~--~~~---~--~~ 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: about cascade rule
On Feb 1, 5:24 am, Manlio Perillo [EMAIL PROTECTED] wrote: Hi. I still do not fully understand cascade rules, however I want to be sure the behaviour below is a feature and not a bug. Did you intend for the B object to be able to not exist? I modified your code to create a b object as well as obj and the transaction worked: obj = A('x') bobj=B('hi') # I modified your constructor to not take the id as well bobj.a=obj sess.save(obj) I'm not sure if it is a bug or feature either but perhaps a different cascade rule will alter the behavior. -Dennis --~--~-~--~~~---~--~~ 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: MapperExtension with options
ah the mapper isnt taking into account the extensions that are local to the query during the _instance() phase. we can add a ticket for that. On Feb 1, 12:08 pm, Dennis [EMAIL PROTECTED] wrote: I wanted to experiment with using a MapperExtension to add a couple of non-mapped properties to a class at load time. def MyExt(MapperExtension): def populate_instance(self, mapper, selectioncontext, row, instance, identitykey, isnew): print Hello World # do some work here return EXT_PASS obj=query(MyObj).options(extension(MyExt)).select() MyExt isn't printing anything though.. Am I missing something? Thanks Dennis --~--~-~--~~~---~--~~ 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: about cascade rule
delete-orphan on the A relationship means, no A is allowed to exist in the database without a parent B. the rule used to be more lax and would only fire off when an A was removed from a B...but that missed a lot of cases. the specificness of the error message indicates its definitely not a bug :) On Feb 1, 7:24 am, Manlio Perillo [EMAIL PROTECTED] wrote: Hi. I still do not fully understand cascade rules, however I want to be sure the behaviour below is a feature and not a bug. Here is the code: from sqlalchemy import * db = create_engine('postgres://manlio:[EMAIL PROTECTED]/test', echo=False) metadata = BoundMetaData(db) a = Table( 'a', metadata, Column('id', Integer, primary_key=True), Column('x', String) ) b = Table( 'b', metadata, Column('uid', String, primary_key=True), Column('id', Integer, ForeignKey(a.c.id)), Column('y', String) ) class A(object): def __init__(self, x): self.x = x class B(object): def __init__(self, id, y): self.id = id self.y = y aMapper = mapper(A, a) bMapper = mapper( B, b, properties={ 'a': relation( A, lazy=False, cascade='all, delete-orphan' ) } ) try: metadata.create_all() conn = db.connect() trans = conn.begin() sess = create_session(bind_to=conn) obj = A('x') sess.save(obj) sess.flush() sess.close() trans.commit() conn.close() finally: metadata.drop_all() When executing this script I obtain: Traceback (most recent call last): File cascade.py, line 52, in ? sess.flush() File /usr/lib/python2.4/site-packages/sqlalchemy/orm/session.py, line 220, in flush self.uow.flush(self, objects) File /usr/lib/python2.4/site-packages/sqlalchemy/orm/unitofwork.py, line 175, in flush if object_mapper(obj)._is_orphan(obj): File /usr/lib/python2.4/site-packages/sqlalchemy/orm/mapper.py, line 232, in _is_orphan raise exceptions.FlushError(instance %s is an unsaved, pending instance and is an orphan (is not attached to %s) % sqlalchemy.exceptions.FlushError: instance __main__.A object at 0xb79d946c is an unsaved, pending instance and is an orphan (is not attached to any parent 'B' instance via that classes' 'a' attribute) [EMAIL PROTECTED]:~/projects/bugs/sqlalchemy$ python cascade.py Traceback (most recent call last): File cascade.py, line 52, in ? sess.flush() File /usr/lib/python2.4/site-packages/sqlalchemy/orm/session.py, line 220, in flush self.uow.flush(self, objects) File /usr/lib/python2.4/site-packages/sqlalchemy/orm/unitofwork.py, line 175, in flush if object_mapper(obj)._is_orphan(obj): File /usr/lib/python2.4/site-packages/sqlalchemy/orm/mapper.py, line 232, in _is_orphan raise exceptions.FlushError(instance %s is an unsaved, pending instance and is an orphan (is not attached to %s) % sqlalchemy.exceptions.FlushError: instance __main__.A object at 0xb79a146c is an unsaved, pending instance and is an orphan (is not attached to any parent 'B' instance via that classes' 'a' attribute) Thanks and regards Manlio Perillo --~--~-~--~~~---~--~~ 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: Tool to check whether DB matches model
well, just making an app in such a way that all the model classes are attached to a single-datamember called model is just one of an infinite number of ways to do MVC. so your app is sort of part of a larger framework (whether that framework explcitly exists or not). On Feb 1, 2007, at 6:21 AM, Paul Johnston wrote: Hi, Well, I see a model as a set of tables. In this particular case, a model is the set of tables created with a particular MetaData object. I guess model is a term from the MVC world, so perhaps there's a better term for SA users. Paul On 1/30/07, Michael Bayer [EMAIL PROTECTED] wrote: what i cant see here is exactly what a model is. if its a TG thing, then this app would belong with Turbogears. --~--~-~--~~~---~--~~ 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] how do I set an engine to autocommit?
I have a program that is entering a deadlock (pyscopg) after an exception since the test suite tries to delete stuff as part of cleanup. I tried wrapping everything in a transaction to be sure a rollback is called but it *appears* that when I start using transaction.session.bind_to.execute(stmt) directly, it is not part of the transaction. All I'm doing are selects anyway (this may be why the transaction is ignored too) so I really don't need a transaction to begin with. How do I set an engine of a session to autocommit? this is what it looks like (roughly)... session = self.session_context.current transaction = session.create_transaction() # with the mapper (seems to be in transaction) rs = session.query(mapped_class).select_whereclause(query_str) # with a table object (does not seem to be in the transaction) stmt = table.select(col==val) engine = transaction.session.bind_to engine.execute(stmt) _ if I can set the engine to auto commit mode I will likely be able to prevent the deadlock. --~--~-~--~~~---~--~~ 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: about cascade rule
Michael Bayer ha scritto: delete-orphan on the A relationship means, no A is allowed to exist in the database without a parent B. the rule used to be more lax and would only fire off when an A was removed from a B...but that missed a lot of cases. the specificness of the error message indicates its definitely not a bug :) Ok, thanks. However this is not well documented in http://www.sqlalchemy.org/docs/unitofwork.myt#unitofwork_cascade Regards Manlio Perillo --~--~-~--~~~---~--~~ 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: MapperExtension with options
On Feb 1, 12:58 pm, Michael Bayer [EMAIL PROTECTED] wrote: ah the mapper isnt taking into account the extensions that are local to the query during the _instance() phase. we can add a ticket for that. http://www.sqlalchemy.org/trac/ticket/454 --~--~-~--~~~---~--~~ 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] Anyone using migrate?
I was considering the use of migrate (http://erosson.com/migrate/) for a new project using SA and I just wondered if anyone else is using it? Are there any plans to integrate this support into a future version of SA? Thanks, Allen --~--~-~--~~~---~--~~ 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 do I set an engine to autocommit?
On Feb 1, 3:02 pm, Kumar McMillan [EMAIL PROTECTED] wrote: I have a program that is entering a deadlock (pyscopg) after an exception since the test suite tries to delete stuff as part of cleanup. I tried wrapping everything in a transaction to be sure a rollback is called but it *appears* that when I start using transaction.session.bind_to.execute(stmt) directly, it is not part of the transaction. uh yeah...why would it be ? youre essentially pulling out the original bind_to engine which has no idea about what particular connection/transaction is used by the SessionTransaction. unless youre playing with the threadlocal engine (which i would advise is not worth it), why not do what the docs say ? http://www.sqlalchemy.org/docs/unitofwork.myt#unitofwork_transaction_sql All I'm doing are selects anyway (this may be why the transaction is ignored too) so I really don't need a transaction to begin with. How do I set an engine of a session to autocommit? any execute() that you call from an engine or connection without an associated transaction will call commit for you, *if* you did something like an INSERT/UPDATE/DELETE/etc. it does not call commit if you just call a select. it actually looks at the string you executed to determine this. --~--~-~--~~~---~--~~ 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 + MySQL encoding error (probably wrong charset=... handling)
dont use the Unicode type if your MySQL client and/or server is converting unicode for you. convert_unicode=False has no effect on the Unicode type. also note theres a bug in MySQLDB related to this: http://sourceforge.net/tracker/index.php?func=detailaid=1592353group_id=22307atid=374932 http://www.sqlalchemy.org/trac/ticket/340 On Feb 1, 7:28 am, Andrew Stromnov [EMAIL PROTECTED] wrote: Python 2.4.4 (win32) + SQLAlchemy (r2285) + MySQLdb 1.2.1 Code: from sqlalchemy import create_engine, BoundMetaData from sqlalchemy import Table, Column, Integer, String, SmallInteger, Unicode dburl1 = 'mysql://login:[EMAIL PROTECTED]/geobase? use_unicode=1charset=cp1251compress=1' engine1 = create_engine(dburl1, echo=False) metadata1 = BoundMetaData(engine1) cities = Table('cities', metadata1, Column('id', Integer, autoincrement=True, primary_key=True), Column('region_id', Integer, nullable=False, default=0), Column('country_id', Integer, nullable=False, default=0), Column('dialcode', String(7), nullable=False, default=''), Column('name', String(64), nullable=False, default=''), Column('mask', String(5), nullable=False, default=''), Column('metro', SmallInteger, nullable=False, default='0') ) dburl2 = 'mysql://login:[EMAIL PROTECTED]/geobase? use_unicode=1charset=utf8' engine2 = create_engine(dburl2, echo=False, convert_unicode=False) metadata2 = BoundMetaData(engine2) places = Table('places', metadata2, Column('id', Integer, autoincrement=True, primary_key=True), Column('name', Unicode(64), nullable=False, default=''), Column('parent', Integer, nullable=False, default=0), Column('left', Integer, nullable=False, default=0), Column('right', Integer, nullable=False, default=0), Column('depth', Integer, nullable=False, default=0), Column('type', Integer, nullable=False, default=0), Column('dialcode', Unicode(7), nullable=True), Column('mask', Unicode(5), nullable=True), Column('code', Integer, nullable=True), Column('domain', Unicode(5), nullable=True), ) # BLOCK cities = cities.select(limit=1).execute().fetchall() # BLOCK iv2 = u'\u0418\u0432\u0430\u043d\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b.' nregion = places.select(places.c.name == iv2).execute() Traceback (most recent call last): File e.py, line 37, in ? nregion = places.select(places.c.name == iv2).execute() File \Python24\Lib\site-packages\sqlalchemy\sql.py, line 476, in execute File \Python24\Lib\site-packages\sqlalchemy\sql.py, line 414, in execute File C:\Python24\lib\site-packages\sqlalchemy\engine\base.py, line 492, in execute_compiled return connection.execute_compiled(compiled, *multiparams, **params) File C:\Python24\lib\site-packages\sqlalchemy\engine\base.py, line 303, in execute_compiled proxy(str(compiled), parameters) File C:\Python24\lib\site-packages\sqlalchemy\engine\base.py, line 299, in proxy self._execute_raw(statement, parameters, cursor=cursor, context=context) File C:\Python24\lib\site-packages\sqlalchemy\engine\base.py, line 337, in _execute_raw self._execute(cursor, statement, parameters, context=context) File C:\Python24\lib\site-packages\sqlalchemy\engine\base.py, line 356, in _execute raise exceptions.SQLError(statement, parameters, e) sqlalchemy.exceptions.SQLError: (UnicodeDecodeError) 'charmap' codec can't decode byte 0x98 in position 1: character maps to undefined 'SELECT places.id, places.name, places.parent, places.`left`, places.`right`, places.depth, places.type, places.dialcode, places.mask, places.code, places.domain \nFROM places \nWHERE places.name = %s' ['\xd0\x98\xd0\xb2\xd0\xb0\xd0\xbd\xd0\xbe \xd0\xb2\xd1\x81\xd0\xba\xd0\xb0\xd1\x8f \xd0\xbe\xd0\xb1\xd0\xbb.'] --~--~-~--~~~---~--~~ 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 do I set an engine to autocommit?
...but it *appears* that when I start using transaction.session.bind_to.execute(stmt) directly, it is not part of the transaction. uh yeah...why would it be ? youre essentially pulling out the original bind_to engine which has no idea about what particular connection/transaction is used by the SessionTransaction. I misunderstood that about how transactions work. Explicitly adding a connection makes sense (but was not intuitive). http://www.sqlalchemy.org/docs/unitofwork.myt#unitofwork_transaction_sql thanks for the link, I completely missed that; thought I'd looked everywhere. _ the fact that the deadlock was solved when I added the connection to the transaction tells me that psycopg runs in commit mode automatically (even though dbapi 2 says it should not). The psycopg docs reinforce this too : http://www.initd.org/tracker/psycopg/wiki/psycopg2_documentation#setting-transaction-isolation-levels this is a little annoying because deadlocks are hard to track down and there is still no way [that I can see] to tell sqlalchemy in an agnostic way : autocommit=False for my engine. I would think this should be allowed like create_engine(dsn, autocommit=1) or as a query string arg in the dsn. Anyway, I can live with forcing everything in a transaction but it is definitely a workaround since all I'm doing are selects. thanks, Kumar --~--~-~--~~~---~--~~ 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 do I set an engine to autocommit?
On 2/1/07, Kumar McMillan [EMAIL PROTECTED] wrote: the fact that the deadlock was solved when I added the connection to the transaction tells me that psycopg runs in commit mode automatically (even though dbapi 2 says it should not). The psycopg docs reinforce this too : http://www.initd.org/tracker/psycopg/wiki/psycopg2_documentation#setting-transaction-isolation-levels Wrong; psycopg2 does not autocommit by default. It automatically _creates new transactions_ but you still have to explicitly commit() or rollback(). This is what DBAPI2 calls for (and is really the only sane thing to do in non-autocommit mode if you think about it). --~--~-~--~~~---~--~~ 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: Anyone using migrate?
I was considering the use of migrate (http://erosson.com/migrate/) for a new project using SA and I just wondered if anyone else is using it? I'm using it, but then, I wrote it. It's worked well for me, though I'm not sure how widely used it is... the mailing list is pretty quiet. Are there any plans to integrate this support into a future version of SA? Nope. Discussed this a while back, and the decision was to keep things separate; the SA core has plenty to do already. --~--~-~--~~~---~--~~ 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 do I set an engine to autocommit?
heh, I was saying it backwards [lack of sleep] but this is what I was referring to ... Note that if the database supports an auto-commit feature, this must be initially off. An interface method may be provided to turn it back on. - http://www.python.org/dev/peps/pep-0249/ ...yes psycopg complies, but sqlalchemy does not expose its interface method to turn autocommit functionality back on. Am I missing it somewhere? I don't see this exposed anywhere in the psycopg dialect nor create_engine(). Deadlocks are not fun to debug. On 2/1/07, Jonathan Ellis [EMAIL PROTECTED] wrote: On 2/1/07, Kumar McMillan [EMAIL PROTECTED] wrote: the fact that the deadlock was solved when I added the connection to the transaction tells me that psycopg runs in commit mode automatically (even though dbapi 2 says it should not). The psycopg docs reinforce this too : http://www.initd.org/tracker/psycopg/wiki/psycopg2_documentation#setting-transaction-isolation-levels Wrong; psycopg2 does not autocommit by default. It automatically _creates new transactions_ but you still have to explicitly commit() or rollback(). This is what DBAPI2 calls for (and is really the only sane thing to do in non-autocommit mode if you think about it). --~--~-~--~~~---~--~~ 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: Anyone using migrate?
On 2/1/07, Evan Rosson [EMAIL PROTECTED] wrote: I was considering the use of migrate (http://erosson.com/migrate/) for a new project using SA and I just wondered if anyone else is using it? I'm using it, but then, I wrote it. It's worked well for me, though I'm not sure how widely used it is... the mailing list is pretty quiet. I noticed the list was quiet. It looks like there have only be a few posts. Is that still the best forum for migrate questions or would it be better to post questions about it to this list to reach a wider audience? Are there any plans to integrate this support into a future version of SA? Nope. Discussed this a while back, and the decision was to keep things separate; the SA core has plenty to do already. Sounds good. Migrate looks like a great tool. Hopefully more people will start using it to manage their database migration with SA. -Allen --~--~-~--~~~---~--~~ 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: Full Text Search using PostgreSQL and tsearch2
Thanks a lot, guys. Will try a sample application and post in the wiki. Might take some time - meanwhile, if somebody gets some more stuff, posting it would help. thankssanjay Really sorry - I could not touch this yet. Have got suddenly busy in preparing for some training, which suddenly creeped in. It might take some more time. Till then if somebody does this, kindly post in the wiki. thanks Sanjay --~--~-~--~~~---~--~~ 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 + MySQL encoding error (probably wrong charset=... handling)
cities = cities.select(limit=1).execute().fetchall() works well with this configuration, but leads to error in nregion = places.select(places.c.name == iv2).execute() if nregion = places.select(places.c.name == iv2).execute() used first, then string conversion error appear at cities = cities.select(limit=1).execute().fetchall() Probably, MySQL charset setting is library-wide, but not connection- wide. On Feb 2, 1:44 am, Michael Bayer [EMAIL PROTECTED] wrote: dont use the Unicode type if your MySQL client and/or server is converting unicode for you. convert_unicode=False has no effect on the Unicode type. also note theres a bug in MySQLDB related to this: http://sourceforge.net/tracker/index.php?func=detailaid=1592353grou...http://www.sqlalchemy.org/trac/ticket/340 On Feb 1, 7:28 am, Andrew Stromnov [EMAIL PROTECTED] wrote: Python 2.4.4 (win32) + SQLAlchemy (r2285) + MySQLdb 1.2.1 Code: from sqlalchemy import create_engine, BoundMetaData from sqlalchemy import Table, Column, Integer, String, SmallInteger, Unicode dburl1 = 'mysql://login:[EMAIL PROTECTED]/geobase? use_unicode=1charset=cp1251compress=1' engine1 = create_engine(dburl1, echo=False) metadata1 = BoundMetaData(engine1) cities = Table('cities', metadata1, Column('id', Integer, autoincrement=True, primary_key=True), Column('region_id', Integer, nullable=False, default=0), Column('country_id', Integer, nullable=False, default=0), Column('dialcode', String(7), nullable=False, default=''), Column('name', String(64), nullable=False, default=''), Column('mask', String(5), nullable=False, default=''), Column('metro', SmallInteger, nullable=False, default='0') ) dburl2 = 'mysql://login:[EMAIL PROTECTED]/geobase? use_unicode=1charset=utf8' engine2 = create_engine(dburl2, echo=False, convert_unicode=False) metadata2 = BoundMetaData(engine2) places = Table('places', metadata2, Column('id', Integer, autoincrement=True, primary_key=True), Column('name', Unicode(64), nullable=False, default=''), Column('parent', Integer, nullable=False, default=0), Column('left', Integer, nullable=False, default=0), Column('right', Integer, nullable=False, default=0), Column('depth', Integer, nullable=False, default=0), Column('type', Integer, nullable=False, default=0), Column('dialcode', Unicode(7), nullable=True), Column('mask', Unicode(5), nullable=True), Column('code', Integer, nullable=True), Column('domain', Unicode(5), nullable=True), ) # BLOCK cities = cities.select(limit=1).execute().fetchall() # BLOCK iv2 = u'\u0418\u0432\u0430\u043d\u043e\u0432\u0441\u043a\u0430\u044f \u043e\u0431\u043b.' nregion = places.select(places.c.name == iv2).execute() Traceback (most recent call last): File e.py, line 37, in ? nregion = places.select(places.c.name == iv2).execute() File \Python24\Lib\site-packages\sqlalchemy\sql.py, line 476, in execute File \Python24\Lib\site-packages\sqlalchemy\sql.py, line 414, in execute File C:\Python24\lib\site-packages\sqlalchemy\engine\base.py, line 492, in execute_compiled return connection.execute_compiled(compiled, *multiparams, **params) File C:\Python24\lib\site-packages\sqlalchemy\engine\base.py, line 303, in execute_compiled proxy(str(compiled), parameters) File C:\Python24\lib\site-packages\sqlalchemy\engine\base.py, line 299, in proxy self._execute_raw(statement, parameters, cursor=cursor, context=context) File C:\Python24\lib\site-packages\sqlalchemy\engine\base.py, line 337, in _execute_raw self._execute(cursor, statement, parameters, context=context) File C:\Python24\lib\site-packages\sqlalchemy\engine\base.py, line 356, in _execute raise exceptions.SQLError(statement, parameters, e) sqlalchemy.exceptions.SQLError: (UnicodeDecodeError) 'charmap' codec can't decode byte 0x98 in position 1: character maps to undefined 'SELECT places.id, places.name, places.parent, places.`left`, places.`right`, places.depth, places.type, places.dialcode, places.mask, places.code, places.domain \nFROM places \nWHERE places.name = %s' ['\xd0\x98\xd0\xb2\xd0\xb0\xd0\xbd\xd0\xbe \xd0\xb2\xd1\x81\xd0\xba\xd0\xb0\xd1\x8f \xd0\xbe\xd0\xb1\xd0\xbb.'] --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---