[sqlalchemy] Re: PostgreSQL - fetching boolean type gives integer type
in sanjay's example, its inserting an integer 1 or 0 value, not True. I think that's the problem. He's saying: What happens is, while fetching, boolean columns are fetched as integer type (0, 1). He's trying to set the show_ads column from the value of another column (directly pulled from the db) So, I suppose a) the columns are boolean, and b) the values were inserted as booleans, otherwise they couldn't have been inserted at all (at least I suppose so; if psycopg complains once, it should always complain about that type-mismatch). Hence the problem is that the value is returned as integer, but needs a boolean to be re-inserted. In my example, I just showed that bool values in my own system *are* returned as bool. It'd be nice now to know from Sanjay which system version is using. -- Alan Franzoni [EMAIL PROTECTED] - Togli .xyz dalla mia email per contattarmi. Remove .xyz from my address in order to contact me. - GPG Key Fingerprint (Key ID = FE068F3E): 5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E --~--~-~--~~~---~--~~ 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: PostgreSQL - fetching boolean type gives integer type
My system was having PostgreSQL 8.1.4 and psycopg. After Alan's code failing in my system, I doubted on psycopg. With some struggle, I successfully installed psycopg2 and removed psycopg, and things worked! Thanks a lot for the diagnosis, guys. Extremely sorry to have bothered you. Understanding SA docs recommending psycopg2, a few days back I had tried to install it. But it gave some error, and I decided not to bother and be happy with psycopg, as it was working without problems for me for last few months. That was the mistake, which drained this timeeffort of all of us. 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: PostgreSQL - fetching boolean type gives integer type
My system was having PostgreSQL 8.1.4 and psycopg. After Alan's code failing in my system, I doubted on psycopg. With some struggle, I successfully installed psycopg2 and removed psycopg, and things worked! You'll find really comfortable with psycopg2. I, too, used psycopg1 till August 2006 or so; then I found out it was dealing very strangely with unicode data. I lurk on the psycopg ML as well, and Fog (psycopg1 2 creator) once said that he's not got enough time to handle both psycopg1 maintenance psycopg2 development, hence he'll fix only highly critical bugs on the 1.x release; any active development is done on release 2.x only right now. -- Alan Franzoni [EMAIL PROTECTED] - Togli .xyz dalla mia email per contattarmi. Remove .xyz from my address in order to contact me. - GPG Key Fingerprint (Key ID = FE068F3E): 5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E --~--~-~--~~~---~--~~ 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] table_foo.c.column_foo.autoincrement returning True always
In order to know whether a column is an autoincrement column, I am checking the above flag. But it is returning True always, irrespective of the column. I am using SQLAlchemy 0.3.3, PostgreSQL 8.1.4 and psycopg2 on fedora 5. Wondering whether it's the correct flag, anything is wrong in my system, or it's a bug. 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: table_foo.c.column_foo.autoincrement returning True always
Sanjay wrote: In order to know whether a column is an autoincrement column, I am checking the above flag. But it is returning True always, irrespective of the column. I am using SQLAlchemy 0.3.3, PostgreSQL 8.1.4 and psycopg2 on fedora 5. Here is a similar post that was replied: http://groups.google.fr/group/sqlalchemy/browse_thread/thread/4ba17b080d97aaf5 Regards, -- Alexandre CONRAD - TLV FRANCE Research Development --~--~-~--~~~---~--~~ 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] SessionTransaction behaviour
Hello, I'm experiencing what I think is an unexpected behaviour using SessionTransaction in SA 0.3.3. The following example is a slightly modified one from SA's SessionTransaction docs. #begin sa_example.py sess = create_session() trans = sess.create_transaction() item1 = sess.query(Reparto).get_by(id=1) item2 = sess.query(Reparto).get_by(id=2) item1.rep_descrizione=uone item2.rep_descrizione=utwo trans.rollback() trans.close() print list(sess) sess.flush() sess.clear() sess.close() sess = create_session() item1 = sess.query(Reparto).get_by(id=1) item2 = sess.query(Reparto).get_by(id=2) print item1.rep_descrizione, item2.rep_descrizione #end sa_example.py I don't know if it's a common doubt or if it's just me that didn't understand something about uow/session behaviour, but I would expect that objects taken into the query during the transaction to be expunged when rolling back the transaction, or at least to be taken back to the values they had when they where pulled from the DB. Of course I can do around this using an 'external' db transaction: #begin sa_example.py conn = engine.connect() dbtrans = conn.begin() sess = create_session(bind_to=conn) #trans = sess.create_transaction() item1 = sess.query(Reparto).get_by(id=1) item2 = sess.query(Reparto).get_by(id=2) item1.rep_descrizione=ufive item2.rep_descrizione=usix sess.flush() dbtrans.rollback() sess.clear() sess.close() sess = create_session() item1 = sess.query(Reparto).get_by(id=1) item2 = sess.query(Reparto).get_by(id=2) print item1.rep_descrizione, item2.rep_descrizione #end sa_example.py But then I don't understand what SessionTransaction is there for? -- Alan Franzoni [EMAIL PROTECTED] - Togli .xyz dalla mia email per contattarmi. Remove .xyz from my address in order to contact me. - GPG Key Fingerprint (Key ID = FE068F3E): 5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E --~--~-~--~~~---~--~~ 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] SqlSoup error
I have the following three tables and trying to do a join. See below for details: g_main ( gene_id serial primary key, . ); g_refseq ( refseq varchar references refseq(refseq), gene_id int references g_main(gene_id) ); refseq ( refseq varchar primary key ); from sqlalchemy.ext.sqlsoup import SqlSoup db = SqlSoup('postgres://user:[EMAIL PROTECTED]/annodb4') genes = db.g_main.select_by(symbol='ADAM12') len(genes) 2 refseqs = db.g_refseq.select_by(gene_id=672) len(refseqs) 13 join1 = db.join(db.g_main,db.g_refseq) Traceback (most recent call last): File stdin, line 1, in module File build/bdist.linux-x86_64/egg/sqlalchemy/ext/sqlsoup.py, line 410, in join File build/bdist.linux-x86_64/egg/sqlalchemy/ext/sqlsoup.py, line 402, in map File build/bdist.linux-x86_64/egg/sqlalchemy/ext/sqlsoup.py, line 369, in class_for_table File build/bdist.linux-x86_64/egg/sqlalchemy/orm/query.py, line 19, in __init__ File build/bdist.linux-x86_64/egg/sqlalchemy/orm/mapper.py, line 252, in compile File build/bdist.linux-x86_64/egg/sqlalchemy/orm/mapper.py, line 270, in _compile_all File build/bdist.linux-x86_64/egg/sqlalchemy/orm/mapper.py, line 497, in _initialize_properties AttributeError: 'Mapper' object has no attribute '_Mapper__props' I am using: SQLAlchemy-0.3.3-py2.5.egg Any suggestions on what I am missing? Thanks, Sean --~--~-~--~~~---~--~~ 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: SqlSoup error
Any suggestions on what I am missing? I don't use sqlsoup and I don't know whether you not using it correctly; btw, if you're in hurry, as a simple workaround, I suggest you add this line to sqlsoup.py, line 369, just above klass_query =... : klass._mapper.compile() and see if it works. -- Alan Franzoni [EMAIL PROTECTED] - Togli .xyz dalla mia email per contattarmi. Remove .xyz from my address in order to contact me. - GPG Key Fingerprint (Key ID = FE068F3E): 5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E --~--~-~--~~~---~--~~ 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: SessionTransaction behaviour
we dont rollback the attributes of objects nor do we automatically expunge() them. its impossible for SA to rollback in-memory objects without great danger of stepping on other program state that the user doesn't want affected.the rollback that is performed by SessionTransaction is a ROLLBACK issued to all database connections that have been gathered up into the transaction, and thats it. any other clear()/expunge() operations are up to the user. --~--~-~--~~~---~--~~ 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: SqlSoup error
On Friday 22 December 2006 10:10, Alan Franzoni wrote: Any suggestions on what I am missing? I don't use sqlsoup and I don't know whether you not using it correctly; btw, if you're in hurry, as a simple workaround, I suggest you add this line to sqlsoup.py, line 369, just above klass_query =... : klass._mapper.compile() and see if it works. Alan, This was, indeed, the fix. And, to clarify for Michael, I did include a primary key on the g_refseq table but neglected to include it in the table def--sorry for being misleading. Thanks for the help. Sean --~--~-~--~~~---~--~~ 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 auto-set timestamp: MySQL func.now(), but not SQLite
Michael Bayer [EMAIL PROTECTED] writes: func.current_timestamp() (which evaulates without the parenthesis in SQL) Excellent, works like a charm. 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: How to auto-set timestamp: MySQL func.now(), but not SQLite
FWIW, that works in MS-SQL and Postgres as well. One of the too-few functions that works cross-DBengine. On 12/22/06, Chris Shenton [EMAIL PROTECTED] wrote: Michael Bayer [EMAIL PROTECTED] writes: func.current_timestamp() (which evaulates without the parenthesis in SQL) Excellent, works like a charm. 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: SqlSoup error
when i put PKs on the table, it worked fine. so that you get the error is disturbing to me since I have tried to insure that there are no paths into a Mapper that wont compile it first. It makes sense that you might have problems I dont, since im testing on OSX whereas you are on linux, and one thing ive noticed about linux is that Python dictionaries produce a very different ordering than whatever you get on OSX (and therefore all kinds of ordering-dependent bugs pop up when i test on linux that dont come up on OSX). so i think there might be a bug here...im going to add a ticket to remind myself to test on linux later. --~--~-~--~~~---~--~~ 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: table_foo.c.column_foo.autoincrement returning True always
I am not reflecting the tables. Example code: from sqlalchemy import * metadata = BoundMetaData('postgres://user:[EMAIL PROTECTED]/mydb', echo=True) company_tbl = Table('company', metadata, Column('company_id', Integer, primary_key=True, autoincrement=True), Column('name', Unicode(30))) metadata.create_all() assert company_tbl.c.company_id.autoincrement == True assert company_tbl.c.name.autoincrement == True# passes! assert company_tbl.c.name.autoincrement == False # fails! 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 -~--~~~~--~~--~--~---