[sqlalchemy] Re: Attribute inheritance problem.
Dnia 2009-07-28, wto o godzinie 11:06 -0400, Michael Bayer pisze: A few things here. First is, I'm not observing the extension not getting inherited. Task().result = 3 raises the error, DeliveryTask().result = 3 does not, and the value is assigned to 3. This is with 0.5.5 as well as trunk. [...] So the sub column_property() needs to reference the original Column: Hm, I fixed it to reference the parent's column, but still: === fi...@cacko:~$ cat sqlawtf.py # Fails with Python-2.5.4 and SQLAlchemy-0.5.5 # There is happening something very strange, which causes # DeliveryTask.result not to cover Task.result even though DeliveryTask # is a child of Task. import sqlalchemy import sqlalchemy.ext.declarative class TefDeclarativeMeta(sqlalchemy.ext.declarative.DeclarativeMeta): def __init__(cls, classname, bases, dict_): if '_decl_class_registry' in cls.__dict__: return type.__init__(cls, classname, bases, dict_) base = bases[0] cls.__tablename__ = cls.__name__ if 'Id' not in dict_.keys(): cls.Id = sqlalchemy.Column(sqlalchemy.types.Integer, sqlalchemy.ForeignKey(base.Id), primary_key=True) if hasattr(base, 'Id'): cls.__mapper_args__ = {'inherit_condition': cls.Id == base.Id, 'polymorphic_identity': cls.__name__} sqlalchemy.ext.declarative._as_declarative(cls, classname, dict_) return type.__init__(cls, classname, bases, dict_) Base = sqlalchemy.ext.declarative.declarative_base(metaclass=TefDeclarativeMeta, mapper=sqlalchemy.orm.mapper) class TefEx(object): def __init__(self, enumDict): self.enumDict = enumDict def set(self, state, value, oldvalue, initiator): if value not in self.enumDict.keys(): raise ValueError(value %s not in %s % (value, self.enumDict)) return value class Task(Base): Id = sqlalchemy.Column( sqlalchemy.types.Integer, primary_key=True, autoincrement=True) objectType = sqlalchemy.Column( sqlalchemy.types.String(128), nullable=False) __mapper_args__ = {'polymorphic_on': objectType} result = sqlalchemy.orm.column_property(sqlalchemy.Column(sqlalchemy.types.Integer), extension = TefEx({0: 'Success', 1: 'Failure'})) class DeliveryTask(Task): result = sqlalchemy.orm.column_property(Task.result, extension = TefEx({0: 'Delivered', 1: 'Rejected', 2: 'Redirected', 3: 'Recipient dead'})) task = DeliveryTask() task.result = 3 fi...@cacko:~$ python sqlawtf.py Traceback (most recent call last): File sqlawtf.py, line 51, in module task.result = 3 File /home/filip/tefnet/teferp/workspace/tefobjects/lib/python2.5/site-packages/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/orm/attributes.py, line 150, in __set__ self.impl.set(instance_state(instance), instance_dict(instance), value, None) File /home/filip/tefnet/teferp/workspace/tefobjects/lib/python2.5/site-packages/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/orm/attributes.py, line 451, in set value = self.fire_replace_event(state, dict_, value, old, initiator) File /home/filip/tefnet/teferp/workspace/tefobjects/lib/python2.5/site-packages/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/orm/attributes.py, line 456, in fire_replace_event value = ext.set(state, value, previous, initiator or self) File sqlawtf.py, line 35, in set raise ValueError(value %s not in %s % (value, self.enumDict)) ValueError: value 3 not in {0: 'Success', 1: 'Failure'} fi...@cacko:~$ === (file available at http://filip.math.uni.lodz.pl/sqlawtf.py)? It is weird that this code works on your machine and doesn't on any of f my setups: * ubuntu 9.04 with Python 2.5.4 (r254:67916, Apr 4 2009, 17:55:16) and SQLAlchemy-0.5.5 at Pentium M 1.3GHz * ubuntu 9.04 with Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) and SQLAlchemy-0.5.4p2 at Pentium M 1.3GHz * ubuntu 9.04 with Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) and SQLAlchemy-0.5.5 at Pentium M 1.3GHz * gentoo with Python 2.5.4 (r254:67916, Apr 4 2009, 17:55:16) and SQLAlchemy-0.5.5 at Intel Atom 330 1.6GHz * gentoo with Python 2.5.2 (r252:60911, Mar 21 2009, 02:12:24) and SQLAlchemy-0.5.5 at 4x Intel Xeon E5335 2.00GHz Funny things happened while developing the project itself - sometimes inheritance would work properly, and sometimes not (even in two consecutive executions). I observed that slowing down the execution increased failure rate (for example with python -m trace -t code.py code.log). For example: fi...@cacko:~/tefnet/teferp/workspace/tefobjects/src/tefobjectsTests$ nosetests EnumProperty_test.py F.E. == ERROR: tefobjectsTests.EnumProperty_test.EnumOk1_test --
[sqlalchemy] Re: Attribute inheritance problem - IRC comment
A short discussion from #sqlalchemy at freenode: [09:48] filip hi, could somebody please run http://filip.eu.org/sqlawtf.py and tell me whether an exception is being raised? [09:49] filip because on my machines it is, and on zzzeek's it is not... [09:55] stepz_ filip: I looked at that a bit, it's some dict ordering thing [09:56] stepz_ 50:50 chance of it failing depending on exact system config [09:56] stepz_ small modifications, or just repeatedly running that in a single interpreter will make it fail [09:58] stepz_ the issue is that while Task.result.impl is not DeliveryTask.result.impl, Task.result.impl.extensions is DeliveryTask.result.impl.extensions [09:58] stepz_ I didn't find at a glance where ScalarAttributeImpl.extensions gets populated so couldn't track the reason [09:59] stepz_ but maybe jek or zzzeek can make something of that [09:59] filip stepz_: it's done this way according to zzzeek's suggestion from the ML [09:59] jezier stepz_: i've traced filips code to sqlalchemy/orm/strategies.py _register_attribute [10:00] jezier stepz_: in for m in mapper.polymorphic_iterator(): you get random order i think bye, Filip Zyzniewski Tefnet --~--~-~--~~~---~--~~ 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: More SA, pyodbc, *nux and MSSQL problems
On 29 Jul 2009, at 05:43, Michael Trier wrote: Hi On Tue, Jul 28, 2009 at 3:14 PM, Ed Singleton singleto...@gmail.com wrote: On 26 Jul 2009, at 15:06, Michael Bayer wrote: i have freetds 0.82, pyodbc 2.1.4. except for binary it mostly works fine (with sqla 0.6). Is that on Mac, Linux or both? Did you do any particular configuration of character encodings? I've worked a lot recently in both of these environments. With Mac and Linux I've experienced the same behavior; that is that you can't pass unicode statements and you can't pass unicode parameters directly, like you can when working just with pyodbc on Windows. With Mac and Linux you need to ensure that: Hmm. I'm definitely getting different behaviours on Mac and Linux. On the Mac, it seems to be working pretty much fine. Linux appears to be working okay as long as all the characters are in the ascii range. This may be complicated by the fact that the database mixes varchar, text, nvarchar and ntext within the same table. It's also complicated by the fact that I know very little about SQL Server, and not that much more about Windows. engine.dialect.supports_unicode = False engine.dialect.supports_unicode_statements = False Additional I've had to set convert_unicode to True and the encoding to Latin1. Thanks for this. This is what I was intending to look into today, so you've saved me quite a bit of time. I've tried it out and the only difference these make, is that I receive lots of warnings about Unicode type received non-unicode bind param value for all the ntext and nvarchar columns. Finally my stack is: Mac: SA - iODBC - FreeTDS - pyodbc - MSSQL Ubuntu: SA - unixODBC - FreeTDS - pyodbc - MSSQL Of course you can remove the xODBC part of the equation if you want, but the results are the same. Are you sure this is correct? I'd understood the order of my stack to be: Mac: SA - pyodbc - unixODBC - FreeTDS - MSSQL Ubuntu: SA - pyodbc - unixODBC - FreeTDS - MSSQL With pyodbc being a layer between SA and freetds, and as you said, xODBC being optional if you don't mind not using DSNs. Thanks Ed --~--~-~--~~~---~--~~ 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] Problems building 0.6 docs
I'm trying to build the docs for SA 0.6 on python2.6 on Mac. I've assumed I need to use Sphinx (which obvously may be quite wrong of me), so I've easy_installed Sphinx and Mako, and then I run the command: mkdir docs sphinx-build doc/build/ docs It appears to read in fine but then raises an error when writing the output. Full stack trace below, and any suggestions greatfully received. Thanks Ed (py26)[singleto...@xander sa06]$ sphinx-build doc/build/ docs Running Sphinx v0.6.2 No builder selected, using default: html loading pickled environment... not found building [html]: targets for 42 source files that are out of date updating environment: 42 added, 0 changed, 0 removed reading sources... [100%] sqlexpression /Users/singletoned/src/sa06/doc/build/dbengine.rst:66: (WARNING/2) Bullet list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/doc/build/dbengine.rst:76: (WARNING/2) Bullet list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/doc/build/dbengine.rst:82: (WARNING/2) Bullet list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/doc/build/intro.rst:: (WARNING/2) Duplicate explicit target name: setuptools. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/expression.py:docstring of sqlalchemy.sql.expression.delete:9: (WARNING/2) Field list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/expression.py:docstring of sqlalchemy.sql.expression.insert:18: (WARNING/2) Field list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/expression.py:docstring of sqlalchemy.sql.expression.insert:22: (WARNING/2) Field list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/expression.py:docstring of sqlalchemy.sql.expression.update:9: (WARNING/2) Field list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/expression.py:docstring of sqlalchemy.sql.expression.Select.correlate:5: (WARNING/2) Block quote ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/expression.py:docstring of sqlalchemy.sql.expression.Select.correlate:8: (WARNING/2) Block quote ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/schema.py:docstring of sqlalchemy.schema.DDL.__init__:41: (WARNING/2) Inline strong start- string without end-string. /Users/singletoned/src/sa06/lib/sqlalchemy/types.py:docstring of sqlalchemy.types.UserDefinedType:19: (WARNING/2) Definition list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/types.py:docstring of sqlalchemy.types.UserDefinedType:24: (WARNING/2) Definition list ends without a blank line; unexpected unindent. looking for now-outdated files... none found pickling environment... done checking consistency... /Users/singletoned/src/sa06/doc/build/ copyright.rst:: WARNING: document isn't included in any toctree done preparing documents... done writing output... [ 2%] copyright Exception occurred: File /Users/singletoned/.envs/py26/lib/python2.6/site-packages/ Mako-0.2.4-py2.6.egg/mako/lookup.py, line 87, in get_template raise exceptions.TopLevelLookupException(Cant locate template for uri '%s' % uri) TopLevelLookupException: Cant locate template for uri 'page.mako' The full traceback has been saved in /var/folders/bK/ bKQXbEG7HeGZtuBOWFYvwTI/-Tmp-/sphinx-err-pCjAfa.log, if you want to report the issue to the author. Please also report this if it was a user error, so that a better error message can be provided next time. Send reports to sphinx-...@googlegroups.com. 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] single table inheritance through declarative.
Hi I am facing a different problem in inheritance. I am using the single table inheritance through declarative. http://www.sqlalchemy.org/docs/05/reference/ext/declarative.html#single-table-inheritance b=Base() b.id='xxx' b.name='xxx' b.type='type1' I am manually setting the type column of my base class. but when i try to commit,it gives the IntegrityError base.type may not be NULL u'INSERT INTO bases (id, name, type, address, login, password) VALUES (?, ?, ?, ?, ?, ?)' ['xxx', 'xxx', None, None, 'xxx','xxx'] I checked this thread, http://groups.google.com/group/sqlalchemy/browse_thread/thread/c646007dce37b11a but I dont have access to the subclass to set the __class__ --~--~-~--~~~---~--~~ 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: Attribute inheritance problem.
Tefnet Developers wrote: Dnia 2009-07-28, wto o godzinie 11:06 -0400, Michael Bayer pisze: A few things here. First is, I'm not observing the extension not getting inherited. Task().result = 3 raises the error, DeliveryTask().result = 3 does not, and the value is assigned to 3. This is with 0.5.5 as well as trunk. [...] So the sub column_property() needs to reference the original Column: Hm, I fixed it to reference the parent's column, but still: having a MapperProperty override a MapperProperty on a base class, while it works, is something SQLA has never supported (since they typically represent columns, which don't inherit in SQL), and we've only just begun to support it in limited cases for concrete table inheritance. so if you can boil down each behavior you see to a self contained test case we can start to add each use case to our test suite. If you're in a hurry, you might want to pursue other styles that don't involve MapperProperty's inheriting.I'd consider the specifics of each class validation being associated with each class for which a single attribute extension on the base class consults. This can be the dictionary approach I outlined, or a distinct callable, and if you don't like it attached directly to the class you can place it in a registry. There's dozens of ways to do this without the need for inheriting SQLA properties. --~--~-~--~~~---~--~~ 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: Attribute inheritance problem - IRC comment
Tefnet Developers wrote: [10:00] jezier stepz_: in for m in mapper.polymorphic_iterator(): you get random order i think While I haven't tested this, based on inspection it should only be random within one level of hierarchy, which shouldn't cause this issue. e.g. D - B - A E - C - A F - A would yield (A), (B, C, F), (D, E) --~--~-~--~~~---~--~~ 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: Problems building 0.6 docs
use the Makefile included in the dist Ed Singleton wrote: I'm trying to build the docs for SA 0.6 on python2.6 on Mac. I've assumed I need to use Sphinx (which obvously may be quite wrong of me), so I've easy_installed Sphinx and Mako, and then I run the command: mkdir docs sphinx-build doc/build/ docs It appears to read in fine but then raises an error when writing the output. Full stack trace below, and any suggestions greatfully received. Thanks Ed (py26)[singleto...@xander sa06]$ sphinx-build doc/build/ docs Running Sphinx v0.6.2 No builder selected, using default: html loading pickled environment... not found building [html]: targets for 42 source files that are out of date updating environment: 42 added, 0 changed, 0 removed reading sources... [100%] sqlexpression /Users/singletoned/src/sa06/doc/build/dbengine.rst:66: (WARNING/2) Bullet list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/doc/build/dbengine.rst:76: (WARNING/2) Bullet list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/doc/build/dbengine.rst:82: (WARNING/2) Bullet list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/doc/build/intro.rst:: (WARNING/2) Duplicate explicit target name: setuptools. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/expression.py:docstring of sqlalchemy.sql.expression.delete:9: (WARNING/2) Field list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/expression.py:docstring of sqlalchemy.sql.expression.insert:18: (WARNING/2) Field list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/expression.py:docstring of sqlalchemy.sql.expression.insert:22: (WARNING/2) Field list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/expression.py:docstring of sqlalchemy.sql.expression.update:9: (WARNING/2) Field list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/expression.py:docstring of sqlalchemy.sql.expression.Select.correlate:5: (WARNING/2) Block quote ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/expression.py:docstring of sqlalchemy.sql.expression.Select.correlate:8: (WARNING/2) Block quote ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/schema.py:docstring of sqlalchemy.schema.DDL.__init__:41: (WARNING/2) Inline strong start- string without end-string. /Users/singletoned/src/sa06/lib/sqlalchemy/types.py:docstring of sqlalchemy.types.UserDefinedType:19: (WARNING/2) Definition list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/types.py:docstring of sqlalchemy.types.UserDefinedType:24: (WARNING/2) Definition list ends without a blank line; unexpected unindent. looking for now-outdated files... none found pickling environment... done checking consistency... /Users/singletoned/src/sa06/doc/build/ copyright.rst:: WARNING: document isn't included in any toctree done preparing documents... done writing output... [ 2%] copyright Exception occurred: File /Users/singletoned/.envs/py26/lib/python2.6/site-packages/ Mako-0.2.4-py2.6.egg/mako/lookup.py, line 87, in get_template raise exceptions.TopLevelLookupException(Cant locate template for uri '%s' % uri) TopLevelLookupException: Cant locate template for uri 'page.mako' The full traceback has been saved in /var/folders/bK/ bKQXbEG7HeGZtuBOWFYvwTI/-Tmp-/sphinx-err-pCjAfa.log, if you want to report the issue to the author. Please also report this if it was a user error, so that a better error message can be provided next time. Send reports to sphinx-...@googlegroups.com. 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: single table inheritance through declarative.
rajasekhar911 wrote: Hi I am facing a different problem in inheritance. I am using the single table inheritance through declarative. http://www.sqlalchemy.org/docs/05/reference/ext/declarative.html#single-table-inheritance b=Base() b.id='xxx' b.name='xxx' b.type='type1' I am manually setting the type column of my base class. but when i try to commit,it gives the IntegrityError base.type may not be NULL u'INSERT INTO bases (id, name, type, address, login, password) VALUES (?, ?, ?, ?, ?, ?)' ['xxx', 'xxx', None, None, 'xxx','xxx'] it sounds like your configuration is missing polymorphic_on. you can't manually set the type column. I checked this thread, http://groups.google.com/group/sqlalchemy/browse_thread/thread/c646007dce37b11a but I dont have access to the subclass to set the __class__ it sounds like you may be using single table inheritance for a purpose which it was not designed. If you don't the desired subclass available at the time of Session.add(), then you don't really need class inheritance in any case. Also I dont really understand what I don't have access means, if you were able to map the class then you should be able to import it. If you just dont know what type x links to what class, store them in a dict somewhere. --~--~-~--~~~---~--~~ 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: Problems building 0.6 docs
Ah thanks, that seems to work fine now. Very grateful. For anyone googling this, use the Makefile means: $ cd doc/build $ make html Ed On 29 Jul 2009, at 16:26, Michael Bayer wrote: use the Makefile included in the dist Ed Singleton wrote: I'm trying to build the docs for SA 0.6 on python2.6 on Mac. I've assumed I need to use Sphinx (which obvously may be quite wrong of me), so I've easy_installed Sphinx and Mako, and then I run the command: mkdir docs sphinx-build doc/build/ docs It appears to read in fine but then raises an error when writing the output. Full stack trace below, and any suggestions greatfully received. Thanks Ed (py26)[singleto...@xander sa06]$ sphinx-build doc/build/ docs Running Sphinx v0.6.2 No builder selected, using default: html loading pickled environment... not found building [html]: targets for 42 source files that are out of date updating environment: 42 added, 0 changed, 0 removed reading sources... [100%] sqlexpression /Users/singletoned/src/sa06/doc/build/dbengine.rst:66: (WARNING/2) Bullet list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/doc/build/dbengine.rst:76: (WARNING/2) Bullet list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/doc/build/dbengine.rst:82: (WARNING/2) Bullet list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/doc/build/intro.rst:: (WARNING/2) Duplicate explicit target name: setuptools. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/ expression.py:docstring of sqlalchemy.sql.expression.delete:9: (WARNING/2) Field list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/ expression.py:docstring of sqlalchemy.sql.expression.insert:18: (WARNING/2) Field list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/ expression.py:docstring of sqlalchemy.sql.expression.insert:22: (WARNING/2) Field list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/ expression.py:docstring of sqlalchemy.sql.expression.update:9: (WARNING/2) Field list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/ expression.py:docstring of sqlalchemy.sql.expression.Select.correlate:5: (WARNING/2) Block quote ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/sql/ expression.py:docstring of sqlalchemy.sql.expression.Select.correlate:8: (WARNING/2) Block quote ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/schema.py:docstring of sqlalchemy.schema.DDL.__init__:41: (WARNING/2) Inline strong start- string without end-string. /Users/singletoned/src/sa06/lib/sqlalchemy/types.py:docstring of sqlalchemy.types.UserDefinedType:19: (WARNING/2) Definition list ends without a blank line; unexpected unindent. /Users/singletoned/src/sa06/lib/sqlalchemy/types.py:docstring of sqlalchemy.types.UserDefinedType:24: (WARNING/2) Definition list ends without a blank line; unexpected unindent. looking for now-outdated files... none found pickling environment... done checking consistency... /Users/singletoned/src/sa06/doc/build/ copyright.rst:: WARNING: document isn't included in any toctree done preparing documents... done writing output... [ 2%] copyright Exception occurred: File /Users/singletoned/.envs/py26/lib/python2.6/site-packages/ Mako-0.2.4-py2.6.egg/mako/lookup.py, line 87, in get_template raise exceptions.TopLevelLookupException(Cant locate template for uri '%s' % uri) TopLevelLookupException: Cant locate template for uri 'page.mako' The full traceback has been saved in /var/folders/bK/ bKQXbEG7HeGZtuBOWFYvwTI/-Tmp-/sphinx-err-pCjAfa.log, if you want to report the issue to the author. Please also report this if it was a user error, so that a better error message can be provided next time. Send reports to sphinx-...@googlegroups.com. 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: More SA, pyodbc, *nux and MSSQL problems
On 25 Jul 2009, at 03:17, mtrier wrote: On Jul 23, 8:30 am, Ed Singleton singleto...@gmail.com wrote: I've managed to get SA (0.6 branch) and pyodbc connecting to anMSSQL db on Mac OS X, but I've recently been trying to get it working on linux (Debian Lenny) and have been hitting some problems. It's definitely working to some degree. Adding TDS_Version = 8.0 to my odbc.ini fixed some unicode problems, and so now simple pyodbc stuff seems to work. Querying seems to be fine, but sometimes adding lots of data using the orm fails with the message: DBAPIError: (Error) ('HY000', 'The driver did not supply an error!') The same error occurs in both SA 0.5.5 and SA 0.6 I'm going to try a few more things to narrow down a bit more where the problem is, but if any has any ideas of what it could be or how I could debug it, I'd be very grateful. Any luck on this? I'm using both with OSX and Ubuntu without differences in behavior. Do you have an isolated test case that duplicates this behavior? I don't yet have an isolated test case that causes the same error, but I do now have an isolated test case that doesn't work, and that I'd like to get working. There's two attached files with reasonably simple cases in. The first, simple_thing.py contains a single example. I've tried tweaking various things in it to various effect. The second, complex_thing.py, contains a test generator that generates 64 tests (for now), testing all the different combinations of things that might affect the success of the test. This one also clearly shows the difference between Mac and Linux on my setup, as on the Mac several of the 'non_ascii£' tests pass. Note that it isn't expected for all the tests to pass. Some of the combinations are wrong. It just shows what works and what doesn't. On both the Mac and Linux, my setup is happy with some unicode queries and/or params. Sometimes it will raise a warning if you are inserting unicode into a non-unicode field, and sometimes it will fail for the same reason. What I'm trying to achieve is: 1) Ability to insert non-ascii chars into the db on Linux 2) The above but for all column types (varchar, text, nvarchar, ntext) Absolutely any ideas will be appreciated. I'm not sure what to try next. For now I'm going to document how I set up Linux. Thanks Ed --~--~-~--~~~---~--~~ 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: More SA, pyodbc, *nux and MSSQL problems
Stupidly forgot to attach the files. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~--- # -*- coding: utf-8 -*- import sqlalchemy as sa from sqlalchemy import Table, Column, MetaData, String from sqlalchemy.orm import mapper, relation from sqlalchemy.dialects.mssql.base import MSNText, MSNVarchar metadata = MetaData() thing_table = Table(ThingTable, metadata, Column(id, String(5), primary_key=True), Column(text_field, MSNText()), ) class ThingTable(object): pass mapper(ThingTable, thing_table) from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker uri = mssql://sa:passwo...@satestdsn2 engine = create_engine(uri) # engine.echo = True metadata.bind = engine Session = sessionmaker(bind=engine) session = Session() metadata.drop_all() session.commit() metadata.create_all() session.commit() thing = ThingTable() thing.id = flib thing.text_field = test£ session.save(thing) session.commit() # -*- coding: latin-1 -*- encoding = 'latin-1' import sqlalchemy as sa from sqlalchemy import Table, Column, MetaData, String, text, create_engine from sqlalchemy.orm import mapper, relation, sessionmaker def get_mapped_table(column_type): metadata = MetaData() uri = mssql://sa:passwo...@satestdsn2 engine = create_engine(uri) engine.dialect.supports_unicode = True engine.dialect.supports_unicode_statements = True engine.dialect.convert_unicode = False engine.dialect.encoding = encoding # engine.echo = True metadata.bind = engine Session = sessionmaker(bind=engine) session = Session() thing_table = Table(ThingTable, metadata, Column(id, String(5), primary_key=True), Column(text_field, getattr(sa.dialects.mssql.base, column_type)()), ) class ThingTable(object): pass mapper(ThingTable, thing_table) metadata.drop_all() metadata.create_all() session.commit() return session, ThingTable def plain_query(column_type, query_data_type, ascii_or_non_ascii_): session, ThingTable = get_mapped_table(column_type) q = uINSERT INTO [ThingTableUnicode] (id, text_field) VALUES ('flib', '%s') % ascii_or_non_ascii_ if query_data_type == str: q = q.encode(encoding) q = text(q) r = session.execute(q) session.rollback() def mapped_query(column_type, query_data_type, ascii_or_non_ascii_): session, ThingTable = get_mapped_table(column_type) thing = ThingTable() thing.id = flib thing.text_field = ascii_or_non_ascii_ session.save(thing) session.commit() session.rollback() def test_run_lots_of_tests(): for ascii_or_non_ascii_ in [ascii, non_ascii£, uascii, unon_ascii£]: for query_data_type in [unicode, str]: for column_type in [MSText, MSNText, MSVarchar, MSNVarchar]: for query_f in [plain_query, mapped_query]: yield query_f, column_type, query_data_type, ascii_or_non_ascii_ On 29 Jul 2009, at 18:27, Ed Singleton wrote: On 25 Jul 2009, at 03:17, mtrier wrote: On Jul 23, 8:30 am, Ed Singleton singleto...@gmail.com wrote: I've managed to get SA (0.6 branch) and pyodbc connecting to anMSSQL db on Mac OS X, but I've recently been trying to get it working on linux (Debian Lenny) and have been hitting some problems. It's definitely working to some degree. Adding TDS_Version = 8.0 to my odbc.ini fixed some unicode problems, and so now simple pyodbc stuff seems to work. Querying seems to be fine, but sometimes adding lots of data using the orm fails with the message: DBAPIError: (Error) ('HY000', 'The driver did not supply an error!') The same error occurs in both SA 0.5.5 and SA 0.6 I'm going to try a few more things to narrow down a bit more where the problem is, but if any has any ideas of what it could be or how I could debug it, I'd be very grateful. Any luck on this? I'm using both with OSX and Ubuntu without differences in behavior. Do you have an isolated test case that duplicates this behavior? I don't yet have an isolated test case that causes the same error, but I do now have an isolated test case that doesn't work, and that I'd like to get working. There's two attached files with reasonably simple cases in. The first, simple_thing.py contains a single example. I've tried tweaking various things in it to various effect. The second, complex_thing.py, contains a test generator that generates 64 tests (for now), testing all the different combinations of things that might affect the success of the test. This one also
[sqlalchemy] logging after engine creation
I was recently trying to change the logging from the default to INFO for sqlalchemy.engine. This works great - so long as I do it at startup, before I make any connections, etc, however once I've created my engine instance I don't seem to be able to change the logging level, at least not in the expected/obvious way. sess = make_session() some_obj = sess.query() logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) sess.refresh(some_obj) I tracked this to the _should_log_info attribute on the engine instance itself. Thus, I would be able to change the level to anything except INFO or DEBUG and get the behavior I expect, but being unable to use INFO or DEBUG (unless set initially) threw me for a bit. I assume that the purpose of this is to save performance? I note that the way much of the logging (esp. in pool.py) seems to be written is like this: somelogger.log(String ... % (var1,var2,var3)) and of course, regardless of the loglevel specified this always interpolates the variables - a fairly significant performance penalty for sure. Shouldn't the style be: somelogger(String ..., var1,var2,var3) which prevents interpolation unless the loglevel is actually sufficient? Would that not obviate the need for _should_log_info (and _should_log_debug) ?? I'm willing to supply a patch that changes the format of the calls to the logging system if that's useful. -- Jon --~--~-~--~~~---~--~~ 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: logging after engine creation
Jon Nelson wrote: I assume that the purpose of this is to save performance? correct. I note that the way much of the logging (esp. in pool.py) seems to be written is like this: somelogger.log(String ... % (var1,var2,var3)) and of course, regardless of the loglevel specified this always interpolates the variables - a fairly significant performance penalty for sure. well no, because all the log statements are underneath conditionals and are not evaluated otherwise. Shouldn't the style be: somelogger(String ..., var1,var2,var3) which prevents interpolation unless the loglevel is actually sufficient? yes, it should. patches are welcome, but again not a big deal. Would that not obviate the need for _should_log_info (and _should_log_debug) ?? unlikely. The conditionals save an enormous number of method calls into the logging package in any case. Python seems to incur an inordinate amount of overhead for method calls. I'm willing to supply a patch that changes the format of the calls to the logging system if that's useful. sure ! if you are curious, try running the tests test_zoomark and test_zoomark_orm to see the method call overhead added by even null logging. --~--~-~--~~~---~--~~ 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: logging after engine creation
Jon Nelson wrote: interpolation. Even if we start out with loglevel=INFO but the log statement is, say, DEBUG we still pay the interpolation penalty (for things like repr or %r, easily far more expensive than the method overhead). we have separate conditionals for INFO and DEBUG so if INFO is enabled, the DEBUGs still don't fire off. --~--~-~--~~~---~--~~ 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] declarative_base vs mapper
Hello, How can I do Index('myindex', xyz.c.type, xyz.c.name, unique=True) in a declarative way? class xyz(DeclarativeBase): __tablename__ = 'xyz' #{ Columns type = Column(Unicode(), nullable=False) name = Column(Unicode(), nullable=False) how do I do index declarative style? Thanks, Lucas -- Using rsync. How to setup rsyncd. http://lucasmanual.com/mywiki/rsync OpenLdap - From start to finish. http://lucasmanual.com/mywiki/OpenLdap --~--~-~--~~~---~--~~ 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] README.unittests: missing command to setup.py
I followed the instructions and they didn't work: The file README.unittests states: $ export PYTHONPATH=. $ python setup.py -d . but this is what I get: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help error: option -d not recognized The command *should* read: python setup.py develop -d . -- Jon --~--~-~--~~~---~--~~ 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: README.unittests: missing command to setup.py
Jon Nelson wrote: I followed the instructions and they didn't work: The file README.unittests states: $ export PYTHONPATH=. $ python setup.py -d . but this is what I get: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help error: option -d not recognized The command *should* read: python setup.py develop -d . thats been fixed in 0.5.5, seems to be still hanging around in 0.6 --~--~-~--~~~---~--~~ 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: declarative_base vs mapper
Here is one approach. I would like to see some way of embedding it in __table_args__, but I haven't been able to figure out that one. t_xyz = xyz.__table__ indx = Index('myindex', t_xyz.c.type, t_xyz.c.name, unique=True) indx.create() or if you put the first 2 lines before metadata.create_all(), then you don't need to separately create the index. -- Mike Conley On Wed, Jul 29, 2009 at 5:34 PM, Lukasz Szybalski szybal...@gmail.comwrote: Hello, How can I do Index('myindex', xyz.c.type, xyz.c.name, unique=True) in a declarative way? class xyz(DeclarativeBase): __tablename__ = 'xyz' #{ Columns type = Column(Unicode(), nullable=False) name = Column(Unicode(), nullable=False) how do I do index declarative style? Thanks, Lucas -- Using rsync. How to setup rsyncd. http://lucasmanual.com/mywiki/rsync OpenLdap - From start to finish. http://lucasmanual.com/mywiki/OpenLdap --~--~-~--~~~---~--~~ 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: declarative_base vs mapper
On Wed, Jul 29, 2009 at 4:34 PM, Lukasz Szybalskiszybal...@gmail.com wrote: Hello, How can I do Index('myindex', xyz.c.type, xyz.c.name, unique=True) in a declarative way? class xyz(DeclarativeBase): __tablename__ = 'xyz' #{ Columns type = Column(Unicode(), nullable=False) name = Column(Unicode(), nullable=False) __table_args__ = (ForeignKeyConstraint(...),UniqueConstraint(...),{}) Actually I needed a primary key on both fields. type = Column(Unicode(), nullable=False, primary_key=True) name = Column(Unicode(), nullable=False,primary_key=True , name=PK_xyz) Now I wonder if name will name my primary key? Do I specify auto_increment=No ? What are the advantages of using declarative way of setting table definitions? vs addressbook_table = sqlalchemy.Table(Addressbook, metadata, sqlalchemy.Column('Address_Sid', sqlalchemy.Integer, primary_key=True), sqlalchemy.Column('FirstName', sqlalchemy.Unicode(40),nullable=False), class Addressbook(object): def __init__(self, **kw): automatically mapping attributes for key, value in kw.iteritems(): setattr(self, key, value) mapper(Addressbook, addressbook_table) It seems to me as its harder to find information on proper syntax then it is with regular table, py object, mapper? Lucas how do I do index declarative style? Thanks, Lucas -- Using rsync. How to setup rsyncd. http://lucasmanual.com/mywiki/rsync OpenLdap - From start to finish. http://lucasmanual.com/mywiki/OpenLdap -- Using rsync. How to setup rsyncd. http://lucasmanual.com/mywiki/rsync OpenLdap - From start to finish. http://lucasmanual.com/mywiki/OpenLdap --~--~-~--~~~---~--~~ 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: declarative_base vs mapper
What are the advantages of using declarative way of setting table definitions? vs addressbook_table = sqlalchemy.Table(Addressbook, metadata, sqlalchemy.Column('Address_Sid', sqlalchemy.Integer, primary_key=True), sqlalchemy.Column('FirstName', sqlalchemy.Unicode(40),nullable=False), class Addressbook(object): def __init__(self, **kw): automatically mapping attributes for key, value in kw.iteritems(): setattr(self, key, value) mapper(Addressbook, addressbook_table) It seems to me as its harder to find information on proper syntax then it is with regular table, py object, mapper? Lucas The declarative is a more concise all-in-one style class Addressbook(Base): __tablename__ = Addressbook Address_Sid = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True) FirstName = sqlalchemy.Column(sqlalchemy.Unicode(40),nullable=False) accomplishes the same thing as the table + class + mapper example including a default __init__() that accepts keywords for column values. I do agree that the examples for declarative need to be more comprehensive. I find it sometimes difficult to translate the mapper style into declarative, but I'm getting better at 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Manually setting the polymorphic type
That seems easy enough, thanks! On Jul 28, 7:25 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jul 28, 2009, at 8:14 PM, NoDamage wrote: Is it possible to manually set the type column of a base class when using single table inheritance? The reason I want to do this is because I am importing data from an external source which does not differentiate between the subclass types. For example: a_table = Table('a', metadata, Column('id', Integer, primary_key=True), Column('type', String(20)), Column('name', String(20)) ) class A(object): pass class B(A): pass a_mapper = mapper(A, a_table, polymorphic_on=a_table.c.type, polymorphic_identity='a', with_polymorphic='*') b_mapper = mapper(B, inherits=a_mapper, polymorphic_identity='b') Here, A is the base class and B is the subclass. I want to be able to do this: a = A() a.type = 'b' session.add(a) result = session.query(A).all() I expect the result to contain an instance of B because I have explicitly set the type to 'b'. But right now, it looks like because I have instantiated an instance of A, the type is overwritten as 'a'. Is there any nice way to do this? you could just say: a.__class__ = B seems a little weird but it is probably the most pythonic way to go. at the moment the flush() process overwrites the type column regardless of what's in it. Theres no hard reason it has to be that way, but im hesitant to change it right now within 0.5 since its been that way for a long time and could break people's applications. --~--~-~--~~~---~--~~ 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: strange problem with relation(..)
On Wed, Jul 29, 2009 at 9:16 PM, Michael Bayermike...@zzzcomputing.com wrote: On Jul 29, 2009, at 10:10 PM, BigJon wrote: On Jul 21, 2:53 pm, Michael Bayer mike...@zzzcomputing.com wrote: Jon Nelson wrote: The parent_id is NOT NULL and has no default. Doing something like this doesn't seem to help, with or without thepost_update=True (or False) configured on the mapper. the NOT NULL makes it impossible, unless you execute a sequence yourself and populate both columns before flushing. node = Node() node.parent = node sess.add(node) sess.flush() The parentid attribute is always None. Is there an easy way to fix this? post_update=True on the parent relation() will run a second UPDATE statement to populate parent_id. Is there any way to make sure of ColumnDefault, DefaultClause, DefaultGenerator, FetchedValue, or PassiveDefault to automatically use the nodeid upon INSERT? sure just use default=my_callable(ctx). the ctx contains the bind parameters for the current row. you could also just use a MapperExtension. I am not sure how to apply a default when not defining the columns - I am sadly using database reflection. I tried using MapperExtension (using before_insert) but nodeid is still None at that point that before_insert is called. Also please direct emails to the mailing list so that everyone can benefit. Of course. An accident. Maybe I just can't do what I'd like to do here. Using post_update=True, I get some desirable behavior and some errors. The desireable behavior: node = Node() node.parent = node ... sess.add(node) sess.flush() that works But now I can't delete nodes. Any of them. The first thing that happens is an UPDATE which tries to set the parentid to None, which then fails. node = get_any_node() sess.delete(node) sess.flush() # boom. an UPDATE statement setting node's parentid to None is attempted, which fails. I am lucky (I guess) that the table has a DDL-level DEFAULT which works, thus even though the column is specified NOT NULL it also has a DEFAULT. This is what allows the initial INSERT to work, then the post_update is run UPDATE'ing the parentid to the correct value (if specified). However, this same NOT NULL bites me because the post_update also executes an UPDATE of the same node being deleted. -- Jon --~--~-~--~~~---~--~~ 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: strange problem with relation(..)
On Jul 29, 2009, at 10:48 PM, Jon Nelson wrote: sure just use default=my_callable(ctx). the ctx contains the bind parameters for the current row. you could also just use a MapperExtension. I am not sure how to apply a default when not defining the columns - I am sadly using database reflection. I tried using MapperExtension (using before_insert) but nodeid is still None at that point that before_insert is called. oh this is MySQL right ? yeah you're out of luck unless you manually generate the ID beforehand. There is no way, well *maybe* a trigger can do it, to insert such a row on MySQL using its normal autoincrement feature and that has nothing to do with SQLAlchemy. see if triggers can do it. otherwise you need to change your schema. I've used a schema like this many times and parent_id simply must be nullable. --~--~-~--~~~---~--~~ 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: strange problem with relation(..)
On Wed, Jul 29, 2009 at 9:54 PM, Michael Bayermike...@zzzcomputing.com wrote: On Jul 29, 2009, at 10:48 PM, Jon Nelson wrote: sure just use default=my_callable(ctx). the ctx contains the bind parameters for the current row. you could also just use a MapperExtension. I am not sure how to apply a default when not defining the columns - I am sadly using database reflection. I tried using MapperExtension (using before_insert) but nodeid is still None at that point that before_insert is called. oh this is MySQL right ? yeah you're out of luck unless you manually generate the ID beforehand. There is no way, well *maybe* a trigger can do it, to insert such a row on MySQL using its normal autoincrement feature and that has nothing to do with SQLAlchemy. see if triggers can do it. otherwise you need to change your schema. I've used a schema like this many times and parent_id simply must be nullable. PostgreSQL. For testing purposes, I've altered the schema so it can be nullable and I'm able to go forward for now. Thanks for the help! -- Jon --~--~-~--~~~---~--~~ 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: More SA, pyodbc, *nux and MSSQL problems
Finally my stack is: Mac: SA - iODBC - FreeTDS - pyodbc - MSSQL Ubuntu: SA - unixODBC - FreeTDS - pyodbc - MSSQL Of course you can remove the xODBC part of the equation if you want, but the results are the same. Are you sure this is correct? I'd understood the order of my stack to be: Mac: SA - pyodbc - unixODBC - FreeTDS - MSSQL Ubuntu: SA - pyodbc - unixODBC - FreeTDS - MSSQL With pyodbc being a layer between SA and freetds, and as you said, xODBC being optional if you don't mind not using DSNs. Sorry my mistake. You are correct. -- Michael Trier http://michaeltrier.com/ http://thisweekindjango.com/ --~--~-~--~~~---~--~~ 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: More SA, pyodbc, *nux and MSSQL problems
Hi, On Wed, Jul 29, 2009 at 1:30 PM, Ed Singleton singleto...@gmail.com wrote: Stupidly forgot to attach the files. What I'm trying to achieve is: 1) Ability to insert non-ascii chars into the db on Linux 2) The above but for all column types (varchar, text, nvarchar, ntext) Absolutely any ideas will be appreciated. I'm not sure what to try next. For now I'm going to document how I set up Linux. Excellent. I'll dig into this tomorrow if I get a chance to see if I can help propel this along. -- Michael Trier http://michaeltrier.com/ http://thisweekindjango.com/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---