Re: [sqlalchemy] SA 0.8.0: Invalid argument(s) 'label_length'
Hi, Michale, Thanks very much! Setting the label_length after the engine creation works for us! Cheers On Thursday, May 23, 2013 2:09:30 AM UTC+10, Michael Bayer wrote: this is a bug that goes back through 0.7, I've added http://www.sqlalchemy.org/trac/ticket/2732 for this. For now I don't think you need the label_length argument, the dialect should have that under control. if you do need it, you can set it after the fact: engine.dialect.label_length = 30 On May 21, 2013, at 11:04 PM, Anthony Kong anthony...@gmail.comjavascript: wrote: Hi, all, I have recently upgraded to use SA 0.8.0. Now when I run this statement, db = create_engine(sybase://, creator=self.buildConnection, echo=echo, label_length=30) it throws a TypeError exception: TypeError: Invalid argument(s) 'label_length' sent to create_engine(), using configuration SybaseDialect_pyodbc/QueuePool/Engine. Please check that the keyword arguments are appropriate for this combination of components. Locals: What is the root cause of it? If I remove 'label_length=30', it will work fine. How can I set this value in 0.8.0? Do I still need to? Cheers, Tony -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com javascript:. To post to this group, send email to sqlal...@googlegroups.comjavascript: . Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sqlalchemy] how to use bind_expression to build an express like 'convert(bit, @value)?
Hi, all, We are upgrading our application to use SA0.8.0. For reason outside our control, some XP workstations are using old sybase ODBC driver and we cannot upgrade them as of yet. The sybase driver will cause this problem in the following situation: 1) we have a table that have a field of type 'bit' to hold boolean value (i.e. 0 for false and 1 for true) 2) we need to select subset data out of this table based on this flag When we run something like session.query(SubProduct).filter(Product.isTradeable==True) we get this error message: DatabaseError: (DatabaseError) Msg 257, Level 16, State 1, Line 1 Implicit conversion from datatype 'CHAR' to 'BIT' is not allowed. Use the CONVERT function to run this query. Msg 257, Level 16, State 1, Line 1 Implicit conversion from datatype 'CHAR' to 'BIT' is not allowed. Use the CONVERT function to run this query. 'SELECT SUBPRODUCT ... WHERE Product.id_tradeable = @id_tradeable_1' {'@id_tradeable_1': '1'} I am trying to put in place a workaround: If I can convert the sql statement to something like so 'SELECT SUBPRODUCT ... WHERE Product.id_tradeable = *convert(bit, @id_tradeable_1)'* {'@id_tradeable_1': '1'} I believe I can avoid the sybase SQL exception regardless of client driver version So I implemented this class import sqlalchemy.types as satypes from sqlalchemy import func from sqlalchemy.sql.expression import type_coerce class SybaseBit( satypes.TypeDecorator): impl = satypes.Boolean def bind_expression(self, bindvalue): # bindvalue = type_coerce(bindvalue, satypes.Integer) return func.convert(bit, bindvalue) It failed because 'bit' is not defined there. If I put in a string 'bit', the generated sql is very close to what I want. So my question is: What is the proper way to implement this? Cheers, Tony -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sqlalchemy] SA 0.8.0: Invalid argument(s) 'label_length'
Hi, all, I have recently upgraded to use SA 0.8.0. Now when I run this statement, db = create_engine(sybase://, creator=self.buildConnection, echo=echo, label_length=30) it throws a TypeError exception: TypeError: Invalid argument(s) 'label_length' sent to create_engine(), using configuration SybaseDialect_pyodbc/QueuePool/Engine. Please check that the keyword arguments are appropriate for this combination of components. Locals: What is the root cause of it? If I remove 'label_length=30', it will work fine. How can I set this value in 0.8.0? Do I still need to? Cheers, Tony -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sqlalchemy] How to insert a new row into a Sybase database table which has an IDENTITY primary key column?
Hi, Micheal, Thanks for the reply. I have added autoincrement to the Column definition of 'id', like so: id = Column(Integer, name='id_trade', primary_key=True, autoincrement=True) In the log I can see the id column is not included in the INSERT statement. I have taken that SQL statement out and run it, and a row can be successfully created in the table. However, it still throws the same exception in python land. And it follows by a ROLLBACK Do I need to do anything related to reload? I suspect may be the row cannot be inserted after all but sqlalchemy does not retrieve @@IDENTITY? Cheers -- 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/-/yhFVlHz44FUJ. 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.
Re: [sqlalchemy] How to insert a new row into a Sybase database table which has an IDENTITY primary key column?
1) Yes, I am working with existing table 2) The id column is not included in the SQL, which is the expected behaviour if we want the server to generate value for the IDENTITY column in sybase/ms-sql 3) ok Any tracing option I can use to see how SQLA deals with the 'id' column? On Thursday, May 10, 2012 5:09:59 AM UTC+10, Michael Bayer wrote: On May 9, 2012, at 4:46 PM, Anthony Kong wrote: Hi, Micheal, Thanks for the reply. I have added autoincrement to the Column definition of 'id', like so: id = Column(Integer, name='id_trade', primary_key=True, autoincrement=True ) that's fine, but the table has to be created that way in the database also, that is, using the IDENTITY keyword explicitly. if you are dealing with an existing database, that may not be the case. In the log I can see the id column is not included in the INSERT statement. I have taken that SQL statement out and run it, and a row can be successfully created in the table. that's also fine but is there a value for the primary key column ? or is it NULL? Do I need to do anything related to reload? I suspect may be the row cannot be inserted after all but sqlalchemy does not retrieve @@IDENTITY? the work SQLA does with @@IDENTITY may not be present in the log output of SQLAlchemy itself. -- 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/-/I6OriBExVeAJ. 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.
Re: [sqlalchemy] How to insert a new row into a Sybase database table which has an IDENTITY primary key column?
I think I have found the root cause of the problem. I am using a sybase database server of version 15 (Adaptive Server Enterprise/15.0.3/EBF 17163) But for various reasons we are still using sybase ODBC driver 12.5. If I switch to 15.5, it just works as expected. *A follow-up question**:* ** Says I must stay with driver 12.5, what are the possible workaround for this issue? I think there are at least two possible solutions: A) Use direct query to insert and retrieve @@identity back form the server B) 'hack' the self.dispatch in session to retrieve @@identity and assign it to the 'id' field in flush() event Do they sound plausible? Are there any pointers/resource on how to achieve the above? Cheers On Thursday, May 10, 2012 7:43:43 AM UTC+10, Anthony Kong wrote: 1) Yes, I am working with existing table 2) The id column is not included in the SQL, which is the expected behaviour if we want the server to generate value for the IDENTITY column in sybase/ms-sql 3) ok Any tracing option I can use to see how SQLA deals with the 'id' column? On Thursday, May 10, 2012 5:09:59 AM UTC+10, Michael Bayer wrote: On May 9, 2012, at 4:46 PM, Anthony Kong wrote: Hi, Micheal, Thanks for the reply. I have added autoincrement to the Column definition of 'id', like so: id = Column(Integer, name='id_trade', primary_key=True, autoincrement=True) that's fine, but the table has to be created that way in the database also, that is, using the IDENTITY keyword explicitly. if you are dealing with an existing database, that may not be the case. In the log I can see the id column is not included in the INSERT statement. I have taken that SQL statement out and run it, and a row can be successfully created in the table. that's also fine but is there a value for the primary key column ? or is it NULL? Do I need to do anything related to reload? I suspect may be the row cannot be inserted after all but sqlalchemy does not retrieve @@IDENTITY? the work SQLA does with @@IDENTITY may not be present in the log output of SQLAlchemy itself. -- 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/-/GzOcXxqMSk0J. 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.