[Sqlalchemy-users] MS SQL engine?
Hi, Has anyone started working on an MS SQL engine that uses pymssql or .. whatever? If not, can anyone suggest which of the existing engines would be the closest match that I can use to write one for ms sql? And .. tips or suggestions for engine writers? -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnkkid=110944bid=241720dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] firebird connection - does autoload work?
I am using 3.2 Kinterbasdb with latest svn sqlalchemy. I've defined tables using autoload, but primary_key = False in all the tables loaded. Also it doesn't seem to create foreign keys either. Anyone know if this is supposed to work with firebird? -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnkkid=110944bid=241720dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
Re: [Sqlalchemy-users] firebird connection - does autoload work?
On 28 Mar 2006 at 13:15, Rick Morrison wrote: That would be me. It's currently misbehaving on binary / unicode data with pymssql, but I was considering posting it anyway for experimental work, as I'm getting tired of resolving conflicts on each svn up. Great, will this go into trunk? When can I start testing it? I'm working on a CRM app for a non-profit. We'll be deploying on Linux with Firebird (hopefully), but right now I'm developing on my Windows laptop.. So could use MSDE to get started with SqlAlchemy. I don't really want to setup Oracle XE .. (is it worth it? Seems huge).. -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnkkid=110944bid=241720dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
Re: [Sqlalchemy-users] firebird connection - does autoload work?
On 28 Mar 2006 at 17:11, Michael Bayer wrote: seems like the maintainer is MIAid have to look up his email address in my folders You're talking about the maintainer of the Firebird module? You should feel free to fix it up ! whoever can contribute, that would be great. Are the sqlalchemy unit tests all in working order and they're all supposed to work with any engine? Which tests are best to start with when developing an engine? Any other tips for engine authors other than .. just subclass the AnsiSQLEngine? -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnkkid=110944bid=241720dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
Re: [Sqlalchemy-users] Transactions and Sessions, proposal #2
On 7 Apr 2006 at 19:00, Michael Bayer wrote: the moral of the story is, if del object takes the reference count down to zero, but Jython is still not going to call __del__ despite this, then the connection pooling in SA needs some major changes to explicitly count checkouts within the same thread, since the current engine implementation relies upon this (i.e. it cant call close() flat-out without a checkout counter because the connection might still be in use in an enclosing stack frame). can we confirm that this is the case ? Referring to : http://itmaurer.com/jython/htdocs/presentation.html it says: Differences between CPython and Jython Some examples: * __del__ is not reliable because the Java garbage collector is used In other words, __del__ should not be used with Jython, since java garbage collection is used and with the JVM, actual collection can be a loonngg time coming. I do not think this is going to change in later versions of Jython. I believe I've read a number of times that relying on __del__ for resource release is not recommended. -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnkkid=110944bid=241720dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] Compound foreign keys
I have tables with compound primary keys, like this: # table task # Individual task for a service task = Table('task', Column('system_id', Integer, primary_key=True, nullable=False, ), Column('id', Integer, Sequence(optional=True), primary_key=True, nullable=False, ), snip Now in another table I want to refer to these task records. (an entirely made up example): sub_task = Table('sub_task', Column('system_id', Integer, primary_key=True, nullable=False, ), Column('id', Integer, Sequence(optional=True), primary_key=True, nullable=False, ), Column('task', Integer, ForeignKey('tasks.id') ), snip But, when sub_task references it's parent task, it also has to include system_id in the join. I guess I have to specify this using a custom join condition in an explicit mapper? something along the lines of the example boston_addresses in the docs? http://www.sqlalchemy.org/docs/adv_datamapping.myt#adv_datamapping_relations_customjoin except I'd use primaryjoin = and_(sub_task.c.task = task.c.id, sub_task.c.system_id = task.c.system_id) Does that seem correct? Or is there an easier way to do this in meta data, perhaps Table accepting some kind of Relationship object? --- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] Firebird compound key mapper get fails
I am using svn update from today.. I am testing with Firebird engine, which I realize may be busted. However I just took a look at the MS-SQL engine and it does the same thing. I have a table with a compound key, like this: Tcontact = Table('contact', Column('system_id', Integer, primary_key=True, nullable=False, ), Column('id', Integer, Sequence(contact_id, optional=True), primary_key=True, nullable=False, ), Column('first_name', String(16), nullable=False, ), snip class contact(object): pass assign_mapper(contact, Tcontact) I use global_connect to connect to a firebird database, and just for giggles try contact.get(1,1) I expect a database sql error, because there aren't any records in the contact table. Instead I get a traceback: contact.get(1,1) Traceback (most recent call last): File stdin, line 1, in ? File e:\prj\sqlalchemy\lib\sqlalchemy\mapping\mapper.py, line 247, in get return self.query.get(*ident, **kwargs) File e:\prj\sqlalchemy\lib\sqlalchemy\mapping\query.py, line 43, in get return self._get(key, ident, **kwargs) File e:\prj\sqlalchemy\lib\sqlalchemy\mapping\query.py, line 205, in _get return self._select_statement(statement, params=params, populate_existing=re load)[0] File e:\prj\sqlalchemy\lib\sqlalchemy\mapping\query.py, line 213, in _select _statement return self.instances(statement.execute(**params), **kwargs) File e:\prj\sqlalchemy\lib\sqlalchemy\sql.py, line 473, in execute return self.using(self.engine).execute(*multiparams, **params) File e:\prj\sqlalchemy\lib\sqlalchemy\sql.py, line 378, in execute return self.compile(*multiparams, **params).execute(*multiparams, **params) File e:\prj\sqlalchemy\lib\sqlalchemy\sql.py, line 386, in compile compiler = self.engine.compiler(self.clauseelement, bindparams) File e:\prj\sqlalchemy\lib\sqlalchemy\ext\proxy.py, line 30, in compiler return self.get_engine().compiler(*args, **kwargs) File e:\prj\sqlalchemy\lib\sqlalchemy\databases\firebird.py, line 105, in co mpiler return FBCompiler(statement, bindparams, engine=self, use_ansi=self._use_ans i, **kwargs) TypeError: __init__() got multiple values for keyword argument 'engine' It seems that proxy.py is passing the engine parameter, but Firebird compiler also passes it as a keyword arguement, so does the MS-SQL engine. def compiler(self, statement, bindparams, **kwargs): return FBCompiler(statement, bindparams, engine=self, use_ansi=self._use_ansi, **kwargs) Hmm, well if I print out kwargs in the compiler method, it's empty: Ah, it seems that the positional args are out of sequence (here's a reason why I don't use positional args) So change firebird compile() to: def compiler(self, statement, bindparams, **kwargs): return FBCompiler(statement, bindparams, engine=self, use_ansi=self._use_ansi, **kwargs) and change FBCompiler.__init__ to be like: def __init__(self, statement, parameters, engine, use_ansi = True, **kwargs): self._outertable = None self._use_ansi = use_ansi ansisql.ANSICompiler.__init__(self, statement, parameters, engine, **kwargs) (though mssql has a cleaner init.. ) But still this fails and I'm afraid I'm out of time. Guess I'll move to ms-sql.. (I now get this error) Traceback (most recent call last): File string, line 1, in ? File e:\prj\sqlalchemy\lib\sqlalchemy\mapping\mapper.py, line 247, in get return self.query.get(*ident, **kwargs) File e:\prj\sqlalchemy\lib\sqlalchemy\mapping\query.py, line 43, in get return self._get(key, ident, **kwargs) File e:\prj\sqlalchemy\lib\sqlalchemy\mapping\query.py, line 205, in _get return self._select_statement(statement, params=params, populate_existing=re load)[0] File e:\prj\sqlalchemy\lib\sqlalchemy\mapping\query.py, line 213, in _select _statement return self.instances(statement.execute(**params), **kwargs) File e:\prj\sqlalchemy\lib\sqlalchemy\sql.py, line 473, in execute return self.using(self.engine).execute(*multiparams, **params) File e:\prj\sqlalchemy\lib\sqlalchemy\sql.py, line 378, in execute return self.compile(*multiparams, **params).execute(*multiparams, **params) File e:\prj\sqlalchemy\lib\sqlalchemy\sql.py, line 387, in compile compiler.compile() File e:\prj\sqlalchemy\lib\sqlalchemy\sql.py, line 344, in compile self.statement.accept_visitor(self) File e:\prj\sqlalchemy\lib\sqlalchemy\sql.py, line 1391, in accept_visitor visitor.visit_select(self) File e:\prj\sqlalchemy\lib\sqlalchemy\ansisql.py, line 304, in visit_select l.accept_visitor(self) File e:\prj\sqlalchemy\lib\sqlalchemy\sql.py, line 1049, in accept_visitor self.obj.accept_visitor(visitor) File e:\prj\sqlalchemy\lib\sqlalchemy\sql.py, line 1075, in accept_visitor
Re: [Sqlalchemy-users] Firebird compound key mapper get fails
Michael Bayer wrote: your last stack trace there is still using the firebird module. yes it is. Sorry my phrasing was poor. I should have said, gee, now I get this error in Firebird, so I will now switch to ms-sql. --- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] rolling back or committing read-only transactions
sorry if this is a faq. I want to use sqlalchemy in a Paste (wsgi) application. For each web request, I need to begin a transaction, then either commit it or rollback depending on wether an exception occurred. I want the begin / commit / rollback will be handled by some wsgi middleware. Looking at the latest online docs, I'm assuming that begin is implicitely handled as needed by the engine. And that if objectstore.commit() is not called, then the engine doesn't commit. But then, neither will it rollback.. Right? But depending on the concurency of the database, this may cause other clients to be blocked while they wait to see if I'm going to modify some data that has been read from some table. So, should I use engine.begin() , objectstore.commit() + engine.commit() and engine.rollback() in the middleware instead? -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements --- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
Re: [Sqlalchemy-users] getting the global proxy engine for transaction management
On 23 May 2006 at 21:01, Luís Bruno wrote: class DatabaseMiddleware(object): def __init__(self, application, global_conf, db_uri=None, echo=False, **kw): This looks very much like the paste.filter_app_factory protocol, don't you agree? You might as well move the assert in the factory method here, I guess. It does, but paste deploy looks for a function, not a class.. So the factory has to be a function. class Manager(object): def __init__(self, *args, **kw): self.aborted = False global_connect(*args, **kw ) self.engine = schema.default_engine.get_engine() self.engine.begin() This is where you've lost me; does this connect to the database on every request? Since you've global_connect()'ed in the middleware's __init__(), I thought you wouldn't need to do anything else than a begin(). I'm using scgi, so default_engine.get_engine() looks in thread_local storage for the db connection. The first webrequest is running in a different thread than main, so without the global_connect() call, get_engine() dies with a key error. anyway, global_connect() caches engines by uri, so it's not too bad. Maybe I'm not getting it, but wouldn't you need to provide each Table() or Mapper() to the response generator? I *think* the MetaData in the -schema branch has a list of tables, so I don't need to provide anything else; delbut I don't think you can get away with just an engine./del ah, yes; you can use engine.tables[name]. Never mind. In my case, the table meta data is generated w/o any engine being specified, so the proxy engine is used then.. The filter just puts the manager instance into the environment, lower down app code does whatever it needs to do with sqlalchemy. In my case, I don't yet need the objectstore access in my app, but I will. So, here's an example app with REST exposure of some data. Module dbtables has my table meta-data (still a work inprogress) def __call__(self, environ, start_response): Generate the response transaction_manager = environ['p2pserver.transaction_manager'] table_name = request.path_info_pop(environ) table = table_name and getattr(dbtables, table_name, None) or None if not table: return httpexceptions.HTTPBadRequest(detail=Invalid tablename %r % table_name)(environ, start_response) request_method = environ['REQUEST_METHOD'] if request_method == 'GET': form = variable_decode(request.parse_formvars(environ)) print form, form id = form.get('id') criteria = form.get('criteria', {}) print criteria, criteria if id: # expect a single record record = table.get(int(id)) results = { 'table_name':table_name, 'id':id, 'record':record or None, } else: args = [] if criteria: for k, v in criteria.items(): args.append(table.c[k] == v) records = table.select(*args).data results = { 'table_name':table_name, 'records':records, 'criteria':criteria or None, } results['columns'] = table.c.keys() else: form = {} results = { 'error':'no request', } response = xml_string(object=results, name=results, policy=self.policy) response = DataApp(response, content_type='text/xml') return response(environ, start_response) -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements --- All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=lnkkid7521bid$8729dat1642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
Re: [Sqlalchemy-users] Externally Maintained Thread pools and SA 0.2
On 29 May 2006 at 13:16, Michael Bayer wrote: Pursuant to this discussion, I propose we change the close() method, illustrated below: result = sometable.select().execute() result.close() to this: result = sometable.select().execute() result.close_connection() to eliminate confusion this may cause. comments ? why do this? the object returned from file() does not have a method called close_file() the object returned from socket.socket() does not have a method called close_socket() isn't result from execute() a result set, that looks like any other result set? I can't see any benefit from renaming the close operation on execute() result sets. -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements --- All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=lnkkid=107521bid=248729dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
Re: [Sqlalchemy-users] Externally Maintained Thread pools and SA 0.2
On 29 May 2006 at 13:09, Michael Bayer wrote: I want to use resultset.close() in ALL of my code, so that it will work correctly under either strategy. go nuts. should all work fine. all the work ive done in this area was designed specifically towards your request for this functionality (obviously, it will be required by others as well). Awsome, thanks a ton! (I like the new website design. The font I think is easier to read too) -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements --- All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=lnkkid=107521bid=248729dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] Rough firebird.py diff for 0.21
I've only tested a very basic table.get() and table.select.. haven't tested updates. (attached) The following section of this message contains a file attachment prepared for transmission using the Internet MIME message format. If you are using Pegasus Mail, or any other MIME-compliant system, you should be able to save it or view it from within your mailer. If you cannot, please ask your system administrator for assistance. File information --- File: firebird-diff.txt Date: 29 May 2006, 17:15 Size: 11224 bytes. Type: Binary firebird-diff.txt Description: Binary data
Re: [Sqlalchemy-users] Rough firebird.py diff for 0.21
On 29 May 2006 at 18:38, Michael Bayer wrote: python test/query.py --dburi=firebird://some_firebird_url --verbose All I get is: E:\prj\src\sqlalchemypython test\query.py --dburi=firebird://sysdba:[EMAIL PROTECTED]/e:/temp/p2p.gdb --verbose ERROR test_column_accessor (__main__.QueryTest) ... ERROR ERROR test_column_accessor_shadow (__main__.QueryTest) ... ERROR ERROR test_column_order_with_simple_query (__main__.QueryTest) ... ERROR ERROR test_column_order_with_text_query (__main__.QueryTest) ... ERROR ERROR test_items (__main__.QueryTest) ... ERROR ERROR test_keys (__main__.QueryTest) ... ERROR ERROR test_len (__main__.QueryTest) ... ERROR ERROR testdelete (__main__.QueryTest) ... ^C (hangs there for a long time) So, echo=True I guess in testbase.py, but I don't see engine output. And ERROR is pretty vague. Where do all the tracebacks go? How come I don't see any engine output? -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements --- All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=lnkkid=107521bid=248729dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] suggestion for threadlocal docs
regarding http://www.sqlalchemy.org/docs/plugins.myt#plugins_threadlocal The example shown uses a locally declared BoundMetaData object in table declaration. I could not get that to work with my setup, instead I had to use: from sqlalchemy.schema import default_metadata Tregion = Table('region', default_metadata, Column('id', Integer, primary_key=True, nullable=False, ), Column('name', String(32), nullable=False, ), ) -- Elsewhere in the wsgi stack I use global_connect, and it assigns the engine to default_metadata. When I used my own locally declared MetaData(), I kept getting an error about no engine found.. So I wonder if some comment should be added to the threadlocal docs that if you want to use global_connect, you have to use sqlalchemy.schema.default_metadata as the table metadata.. Or, maybe global_connect() accepts an arg that can specify the metadata object to use? -- Brad Clements, [EMAIL PROTECTED] (315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements
[Sqlalchemy-users] Class relationship diagram, howto write an Engine .. DB2
So I am still chipping away on the Firebird engine by just blindly poking it with a stick. But I will need DB2 support in the future. It would be nice to have a diagram that shows how the different classes relate with each other. Execution, Dialect, Connection, Transaction, etc.. Anyway, I realize everyone is busy, so just tossing that out there as a wishlist item.. some notes / tips for engine writers so we could get more engines supported. Is anyone else working on DB2 support? -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements --- All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=lnkkid=107521bid=248729dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
Re: [Sqlalchemy-users] suggestion for threadlocal docs
On 30 May 2006 at 14:26, Michael Bayer wrote: um yeah the docs for global_connect got whacked, and also the default metadata behavior did too, the way thats supposed to work is you make the Table with no metadata at all, and it would fall back on the default_metadataso you wouldnt need to import it. leaving out metadata didn't work. I got errors because something was looking for 'engine' attribute on the first column object. -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements --- All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=lnkkid=107521bid=248729dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] getting extra engine params from url
I am trying to figure out how to get extra engine specific params from the db url. What I'd like is a url object that populates the standard attributes: self.drivername = drivername self.username = username self.password = password self.host = host self.port = port self.database= database Then has another dictionary of any other connect params that were passed.. So firebird://user:[EMAIL PROTECTED]:port/e:/temp/mydb.gdb?init=200 would have url with self.extra_params = {'init':'200'} URL.translate_connect_args just seems totally odd to me.. Like I give it a list of attributes that I want extracted into a dict.. but, I guess I have to know the order of elements in attribute_names in this method. strange.. I digress. The engine.url._parse_keyvalue_args method seems to be half of what I want.. but make_url doesn't use it.. In fact, nothing does. looks like I need to submit a patch for url.py to allow extra args to get parsed out of a url. -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements --- All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=lnkkid=107521bid=248729dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] possible bug in db.execute handling of positional args
in tests/query/QueryTest.test_len r = db.execute('select user_name from query_users', {}).fetchone() What happens is do_execute gets statement 'select user_name, user_id from query_users' params {} notice that params is type dict, not type [] so, kinterbasdb complains InterfaceError: (0, 'Input parameter container must be a non-string sequence.') same problem in test_column_order_with_text_query -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements --- All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=lnkkid=107521bid=248729dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] test_column_accessor_shadow
Firebird now passes all tests in Query except for test_column_accessor_shadow. It fails probably because __ is not allowed in column names. Is the purpose of this test to test allowed column names, or to test hiding columns that have been declared private? If the later, is there some other mechanism (perhaps an arg passed to Column()) that can be used to declare a column as hidden.. This way other databases could use this feature as well (and pass the test). -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements --- All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=lnkkid=107521bid=248729dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] mapper / testcount
Firebird treats the word 'count' as a keyword, so mapper / testcount does this: mapper(User, users) q = create_session().query(User) self.assert_(q.count()==3) self.assert_(q.count(users.c.user_id.in_(8,9))==2) self.assert_(q.count_by(user_name='fred')==1) which produces: SQL error code = -104\n Token unknown - line 1, column 20\n count') 'SELECT count(?) AS count \nFROM users' [1] Is it safe to change sql.py/ FromClause and TableClause count() to use a different label than count? Since in this case, the count method is returning it's value, the actual label used doesn't seem to matter. Also, Firebird only allows count(*) or count(column_ref) So I am not sure how func.count(1) is supposed to be handled. Where in the engine do I override the handling of count? I couldn't trace much beyond sql.FunctionGenerator. Somehow the engine needs a crack at changing count.. -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements --- All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=lnkkid=107521bid=248729dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] Better Firebird patch and test patches
The attached firebird engine passes 14 query tests and 48 mapper tests. It also passes some reflection tests, but doesn't extract foreign keys or indexes yet. Attached are some minor changes to tests. The reflection diff changes 'value' to 'val', since 'value' is a keyword for firebird. Currently the firebird engine is hardcoded to call kinterbasdb.init(200). However I really want to change this so that url.py can parse out extra engine specific params. I need to pass type_conv and concurrency_level to init in the future. -- A lot of tests fail, but they seem to have nothing to do with the engine under test. It would be helpful to know which tests were in-progress in the trunk and which were are supposed to work.. thanks! -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements The following section of this message contains a file attachment prepared for transmission using the Internet MIME message format. If you are using Pegasus Mail, or any other MIME-compliant system, you should be able to save it or view it from within your mailer. If you cannot, please ask your system administrator for assistance. File information --- File: firebird-diff.txt Date: 30 May 2006, 20:51 Size: 9656 bytes. Type: Binary firebird-diff.txt Description: Binary data The following section of this message contains a file attachment prepared for transmission using the Internet MIME message format. If you are using Pegasus Mail, or any other MIME-compliant system, you should be able to save it or view it from within your mailer. If you cannot, please ask your system administrator for assistance. File information --- File: test-firebird-diff.txt Date: 30 May 2006, 20:52 Size: 2790 bytes. Type: Binary test-firebird-diff.txt Description: Binary data
Re: [Sqlalchemy-users] Better Firebird patch and test patches
On 30 May 2006 at 21:05, Michael Bayer wrote: Copies to: sqlalchemy-users sqlalchemy-users@lists.sourceforge.net From: Michael Bayer [EMAIL PROTECTED] Subject:Re: [Sqlalchemy-users] Better Firebird patch and test patches Date sent: Tue, 30 May 2006 21:05:26 -0400 To: Brad Clements [EMAIL PROTECTED] ok what do you want here, dbengine://user:[EMAIL PROTECTED]:port/database? opt=valopt=val ? as long as its good with RFC1738. did you send me a patch ? i lost track today. also how do you want to approach name conflicts between databases ? do you want to prefix each name with the drivername ? otherwise those URLs are still not agnostic. I did not send a patch. I'm looking at the regex in url._parse_rfc1738_args and trying to decide if I can just change it to.. pattern = re.compile(r''' (\w+):// (?: ([^:]*) (?::(.*))? @)? (?: ([^/:]*) (?::([^/]*))? )? (?:/[^?]*)? (?:?(.*))? ''' , re.X) Not sure if I grok the pattern here correctly, but basically saying that the database part can have anything except '?' and add a new optional group that comes after a '?' then, if that match is true, that part will be passed through cgi.parse_qsl and the resultant dict stuck into the URL object as .. 'extra_args' or something like that. Regarding prefixing these extra args.. I don't see why that'd be necessary, since engines would have to pull out whatever args they're looking for from the URL object, and an engine is only going to get args for which it was the named 'scheme' in the uri anyway. so if two engines each look for a '?init=True', I can't see how that matters. all 273 tests in the trunk at the moment pass on mysql, postgres, and sqlite. tests that arent supported for a certain DB (like sequences for mysql) have an unsupported decorator for that database, so they pass too.so for any test, if for example 'sqlite' is not marked as unsupported, then that test passes on sqlite. if not, then something weird is going on, maybe your version of sqlite or something about the windows environment (i havent run the tests on windows in many weeks, perhaps its time to do that). well, test/select.py fails as follows, I don't see any engine calls there or any firebird.py on the stack (wondering why postgres.dialect() is in there. == FAIL: testcast (__main__.SelectTest) -- Traceback (most recent call last): File test\select.py, line 551, in testcast check_results(postgres.dialect(), ['NUMERIC(10, 2)', 'NUMERIC(12, 9)', 'DATE ', 'TEXT', 'VARCHAR(20)'], '%(literal)s') File test\select.py, line 546, in check_results self.assertEqual(str(cast(1234, TEXT).compile(dialect=dialect)), 'CAST(%s AS %s)' %(literal, expected_results[3])) AssertionError: 'CAST(:literal AS TEXT)' != 'CAST(%(literal)s AS TEXT)' == FAIL: testouterjoin (__main__.SelectTest) -- Traceback (most recent call last): File test\select.py, line 484, in testouterjoin dialect=postgres.dialect() File test\select.py, line 59, in runtest self.assert_(cc == result, str(c) + \n does not match \n + result) AssertionError: SELECT mytable.myid, mytable.name, mytable.description, myothert able.otherid, myothertable.othername FROM mytable LEFT OUTER JOIN myothertable ON mytable.myid = myothertable.otherid WHERE mytable.name = :mytable_name AND mytable.myid = :mytable_myid AND myothert able.othername != :myothertable_othername AND EXISTS (select yay from foo where boo = lar) does not match SELECT mytable.myid, mytable.name, mytable.description, myothertable.otherid, my othertable.othername FROM mytable LEFT OUTER JOIN myothertable ON mytable.myid = myothertable.otherid WHERE mytable.name = %(mytable_name)s AND mytable.myid = % (mytable_myid)s AND myothertable.othername != %(myothertable_othername)s AND EXI STS (select yay from foo where boo = lar) == FAIL: testtextbinds (__main__.SelectTest) -- Traceback (most recent call last): File test\select.py, line 305, in testtextbinds dialect=dialect File test\select.py, line 59, in runtest self.assert_(cc == result, str(c) + \n does not match \n + result) AssertionError: select * from foo where lala=:bar and hoho=:whee does not match select * from foo where lala=%(bar)s and hoho=%(whee)s -- Ran 39 tests in 0.125s FAILED
[Sqlalchemy-users] firebird patch for datetime
I think this patch got lost. it fixes Firebird so that Date columns are not treated like DateTime columns. -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements The following section of this message contains a file attachment prepared for transmission using the Internet MIME message format. If you are using Pegasus Mail, or any other MIME-compliant system, you should be able to save it or view it from within your mailer. If you cannot, please ask your system administrator for assistance. File information --- File: firebird-diff.txt Date: 2 Jun 2006, 12:09 Size: 868 bytes. Type: Binary firebird-diff.txt Description: Binary data ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] objectstore.flush leads to InvalidRequestError(This Connection is closed)
This code used to work, but I think a recent svn up busted it. Now using Rev 1577 I am using sqlalchemy.mods.threadlocal I execute the following code multiple times within a single process invocation. objectstore is sqlalchemy.objectstore. If I comment out the objecstore.flush() call, then I don't get an error, but nothing gets inserted into the database. If I leave objectstore.flush() in-place, I get a traceback when loading the 2nd csv file. Perhaps I mis-understand how this is supposed to work? def load_csv_file(file_name): Load specified csv file into database engine = get_db_engine(echo=True) # calls global_connect # strategy=threadlocal engine.begin() tablename = os.path.splitext(os.path.basename(file_name))[0] print processing , tablename table = getattr(database,tablename) c = csv.DictReader(file(file_name, 'rU')) for row in c: for k, v in row.items(): if v == '': row[k] = None if k == 'id': row[k] = int(v) id = row['id'] record = table.get(id) if not record: record = table() for k, v in row.items(): setattr(record, k, v) objectstore.flush() engine.commit() processing contact_type processing county Traceback (most recent call last): File ..\..\Python\p2p\database\util.py, line 62, in ? main() File ..\..\Python\p2p\database\util.py, line 56, in main load_directory(directory=options.load_directory) File ..\..\Python\p2p\database\util.py, line 12, in load_directory load_csv_file(file_name) File ..\..\Python\p2p\database\util.py, line 32, in load_csv_file record = table.get(id) File e:\prj\sqlalchemy\lib\sqlalchemy\ext\assignmapper.py, line 7, in do return getattr(query, name)(*args, **kwargs) File e:\prj\sqlalchemy\lib\sqlalchemy\orm\query.py, line 43, in get return self._get(key, ident, **kwargs) File e:\prj\sqlalchemy\lib\sqlalchemy\orm\query.py, line 285, in _get return self._select_statement(statement, params=params, populate_existing=re load)[0] File e:\prj\sqlalchemy\lib\sqlalchemy\orm\query.py, line 293, in _select_sta tement return self.instances(statement, params=params, **kwargs) File e:\prj\sqlalchemy\lib\sqlalchemy\orm\query.py, line 255, in instances result = self.session.execute(self.mapper, clauseelement, params=params) File e:\prj\sqlalchemy\lib\sqlalchemy\orm\session.py, line 114, in execute return self.connection(mapper, close_with_result=True).execute(clause, param s, **kwargs) File e:\prj\sqlalchemy\lib\sqlalchemy\engine\base.py, line 240, in execute return Connection.executors[type(object).__mro__[-2]](self, object, *multipa rams, **params) File e:\prj\sqlalchemy\lib\sqlalchemy\engine\base.py, line 264, in execute_c lauseelement return self.execute_compiled(elem.compile(engine=self.__engine, parameters=p aram), *multiparams, **params) File e:\prj\sqlalchemy\lib\sqlalchemy\engine\base.py, line 267, in execute_c ompiled cursor = self.connection.cursor() File e:\prj\sqlalchemy\lib\sqlalchemy\engine\base.py, line 184, in _get_conn ection raise exceptions.InvalidRequestError(This Connection is closed) sqlalchemy.exceptions.InvalidRequestError: This Connection is closed ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] Firebird Patch supports type_conv and concurrency_level
This patch adds support for kinterbasdb.init() args specified in the dburi type_conv (defaults to 200) concurrency_level (defaults to 1) usage would be like dburi = firebird://sysdba:[EMAIL PROTECTED]:someport/path/database.gdb?type_conv=200concurrency_level=1 Index: E:/prj/sqlalchemy/lib/sqlalchemy/databases/firebird.py === --- E:/prj/sqlalchemy/lib/sqlalchemy/databases/firebird.py (revision 1577) +++ E:/prj/sqlalchemy/lib/sqlalchemy/databases/firebird.py (working copy) @@ -5,7 +5,7 @@ # the MIT License: http://www.opensource.org/licenses/mit-license.php -import sys, StringIO, string +import sys, StringIO, string, types import sqlalchemy.engine.default as default # import sqlalchemy.sql as sql @@ -21,8 +21,9 @@ dbmodule = kinterbasdb -kinterbasdb.init(200)# fix this, init args should be passable via db_uri +_initialized_kb = False + class FBNumeric(sqltypes.Numeric): def get_col_spec(self): return NUMERIC(%(precision)s, %(length)s) % {'precision': self.precision, 'length' : self.length} @@ -99,8 +100,21 @@ class FireBirdDialect(ansisql.ANSIDialect): def __init__(self, module = None, **params): +global _initialized_kb self.module = module or dbmodule self.opts = {} + +if not _initialized_kb: +_initialized_kb = True +type_conv = params.get('type_conv', 200) or 200 +if isinstance(type_conv, types.StringTypes): +type_conv = int(type_conv) + +concurrency_level = params.get('concurrency_level', 1) or 1 +if isinstance(concurrency_level, types.StringTypes): +concurrency_level = int(concurrency_level) + +kinterbasdb.init(type_conv=type_conv, concurrency_level=concurrency_level) ansisql.ANSIDialect.__init__(self, **params) def create_connect_args(self, url): @@ -111,7 +125,6 @@ del opts['port'] self.opts = opts -print opts %r % self.opts return ([], self.opts) def connect_args(self): ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
Re: [Sqlalchemy-users] Firebird Patch supports type_conv and concurrency_level
On 6 Jun 2006 at 16:48, Maciej Szumocki wrote: dburi = firebird://sysdba:[EMAIL PROTECTED]:someport/path/database.gdb?type _conv=200concurrency_level=1 What about passing dictionary of type conversions as type_conv to kinterbasdb.init? FBDialect checks the data type of type_conv. If the data type of type_conv is type string, it converts it to an int before passing to kinterbasdb. Otherwise it's passed as-is. same for concurrency_level So, if you instantiate the engine yourself, I think you can pass anything other than a string for type_conv and concurrency_level -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] strange initialization problem with latest trunk
I have code that's been working with an earlier version of 0.2 after svn up tonight I find this odd behaviour, that is table.c is busted until the first query is executed. Then that table starts working, but other tables are broken too until I perform a select on them. Revision: 1654 -- I'm using sqlalchemy w/ python2.4 on windows with paste table.c.keys() returns an empty list AND this code fails on when building up the query (that is, table.c[k] raises an error) (for example, k='id') args = [] if criteria: for k, v in criteria.items(): args.append(table.c[k] == v) # if there's no criteria or whatever, so they # want everything. Need an extra arg to # allow dumping everything if args or form.get('selectall'): records = table.select(*args) However if I execute a query without any criteria first, THEN table.c.keys() works and table.c['id'] works to clarify 1. start up paste app 2. try table.c['id'] == '1' and I get this exception: File 'E:\\prj\\src\\eclipse\\parent_to_parent\\Web\\p2pserver\\p2pserver\\dbaccess.py', line 66 in __call__ args.append(table.c[k] == v) File 'e:\\prj\\src\\sqlalchemy\\lib\\sqlalchemy\\util.py', line 114 in __getitem__ return self.__data[key] File 'e:\\prj\\src\\sqlalchemy\\lib\\sqlalchemy\\util.py', line 174 in __getitem__ return dict.__getitem__(self, key) exceptions.KeyError: 'id' 3. or table.c.keys() returns [] 4. then try table.select(*[]) that returns all rows in the table ok 5. and now table.c.keys() returns the columns and table.c['id'] works 6. try another table, and it's also broken until a select is performed. -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
Re: [Sqlalchemy-users] strange initialization problem with latest trunk
On 26 Jun 2006 at 15:30, Michael Bayer wrote: I made a change that should fix this in changeset 1660. It appears to be fixed, thanks -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] mapper.options - attribute error
SVN revision 1666 I am looking at More on Mapper Options on http://sqlalchemy.org/docs/adv_datamapping.myt I have a generic wsgi middleware that takes a table name and returns data from that table. For one table, I want to hide one field. That is, for table named 'coordinator' I want to NOT return the c_password field (but only when accessed via wsgi) So from the above URL it looks like I could do this from sqlalchemy import * from sqlalchemy.mods.threadlocal import * from sqlalchemy.schema import default_metadata Tcoordinator = Table('coordinator', metadata, Column('region_id', Integer, primary_key=True, nullable=False, ), Column('id', Integer, Sequence(coordinator_id, optional=True), primary_key=True, nullable=False, ), Column('c_password', String(12), nullable=False, ), ) class coordinator(object): pass assign_mapper(coordinator, Tcoordinator) # now, coordinator should be a mapper object itself?) if request_method == 'GET': if table_name == 'coordinator': table = coordinator # actually done via a getattr on a module # modify the mapper table = table.options(noload('c_password')) record = table.get(int(id)) results = { 'table_name':table_name, 'id':id, 'record':record or None, } But this doesn't work, I get: File 'E:\\prj\\src\\eclipse\\parent_to_parent\\Web\\p2pserver\\p2pserver\\dbaccess.py', line 50 in __call__ table = table.options(noload('c_password')) exceptions.AttributeError: type object 'coordinator' has no attribute 'options' I thought that assign_mapper assigned all the attributes of a mapper to it's class (get, select, etc) But maybe options was left out? So then I tried this: if table_name == 'coordinator': # modify the mapper table = table.mapper.options(noload('c_password')) But now I get this error: File 'E:\\prj\\src\\eclipse\\parent_to_parent\\Web\\p2pserver\\p2pserver\\database.py', line 42 in __call__ ok_callback=manager.finish) File 'e:\\prj\\src\\paste\\paste\\wsgilib.py', line 114 in catch_errors app_iter = application(environ, start_response) File 'e:\\prj\\src\\paste\\paste\\urlmap.py', line 202 in __call__ return app(environ, start_response) File 'E:\\prj\\src\\eclipse\\parent_to_parent\\Web\\p2pserver\\p2pserver\\dbaccess.py', line 51 in __call__ table = table.mapper.options(noload('c_password')) File 'e:\\prj\\src\\sqlalchemy\\lib\\sqlalchemy\\orm\\mapper.py', line 717 in options option.process(mapper) File 'e:\\prj\\src\\sqlalchemy\\lib\\sqlalchemy\\orm\\properties.py', line 643 in process self.process_by_key(mapper, self.key) File 'e:\\prj\\src\\sqlalchemy\\lib\\sqlalchemy\\orm\\properties.py', line 652 in process_by_key self.create_prop(mapper, tokens[0]) File 'e:\\prj\\src\\sqlalchemy\\lib\\sqlalchemy\\orm\\properties.py', line 729 in create_prop mapper._compile_property(key, newprop) File 'e:\\prj\\src\\sqlalchemy\\lib\\sqlalchemy\\orm\\mapper.py', line 602 in _compile_property prop.init(key, self) File 'e:\\prj\\src\\sqlalchemy\\lib\\sqlalchemy\\orm\\mapper.py', line 1167 in init self.do_init(key, parent) File 'e:\\prj\\src\\sqlalchemy\\lib\\sqlalchemy\\orm\\properties.py', line 198 in do_init if isinstance(self.argument, type): exceptions.AttributeError: 'PropertyLoader' object has no attribute 'argument' So then I tried this instead (pretty much copied from the website) if table_name == 'coordinator': # modify the mapper table = class_mapper(table).options(noload('c_password')) But I get the same exception: exceptions.AttributeError: 'PropertyLoader' object has no attribute 'argument' What am I doing wrong? -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
Re: [Sqlalchemy-users] mapper.options - attribute error
On 26 Jun 2006 at 22:10, Michael Bayer wrote: noload() is used only for multi-table relations(), to indicate that a secondary relation should not be eager or lazy loaded. Oh. Yeah, I thought noload would work like defer. The docs aren't clear that the load options (eager, lazy, no) are only for related tables and not attributes. And reading the docstring for noload, it's very similar to the docstring for defer. what about assign_mapper not putting options() on the class? Is that an oversight? what youre looking for is almost like deferred column loading (http://www.sqlalchemy.org/docs/ adv_datamapping.myt#advdatamapping_properties_deferred) but i guess you are doing this more for security reasons rather than performance. i dont know if SA really has a feature that exactly fits that idea...you could try making a second mapper that maps to a select statement, which doesnt include the column that you want to obscure. or, just have your mapped object hide the field (youre not exposing the object to untrusted code, are you?) The returned row object is converted to XML by code that dumps __dict__ contents. I just changed noload to defer and hey, it does what I want. Probably works because I'm accessing the __dict__ directly rather than going through the object's __getitem__ or __getattr__ -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
Re: [Sqlalchemy-users] SQLAlchemy 0.2.4 released - Firebird Patch missing?
I see my last Firebird patch still hasn't been applied. It's the one that adds support for type_conv I submitted it 2 or 3 times already. I've attached it again. -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements The following section of this message contains a file attachment prepared for transmission using the Internet MIME message format. If you are using Pegasus Mail, or any other MIME-compliant system, you should be able to save it or view it from within your mailer. If you cannot, please ask your system administrator for assistance. File information --- File: firebird-diff.txt Date: 28 Jun 2006, 13:52 Size: 2634 bytes. Type: Binary firebird-diff.txt Description: Binary data Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
Re: [Sqlalchemy-users] SQLAlchemy 0.2.4 released - Firebird Patch missing?
On 28 Jun 2006 at 15:04, Michael Bayer wrote: first im seeing it for wahtever reason committed in 1672. Thanks. I think I first sent it to the list when it got jammed up 2 or 3 weeks ago, then I sent you a direct copy along with some other problem reports, so maybe it got lost there. No matter. (hm thought you were in the users file...i can set you up with that) I don't think that's necessary, I'm happy to have others vet my patches before applying them. ;-) -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] mapper extension before_insert / before_update busted
Revision: 1712 (first time I've tried this so I don't know if it's recent breakage) Tcontact = Table('contact' ... ) class contact(object): pass assign_mapper(contact, Tcontact, extension=[ table_extensions.contact(), ]) in table_extensions.py: class contact(MapperExtension): def __init__(self): print in contact extension init super(contact, self).__init__() def before_insert(self, mapper, connection, instance): print on before insert %r % instance update_contact_soundex_name(instance) def before_update(self, mapper, connection, instance): print on before update %r % instance update_contact_soundex_name(instance) inserting a new record or updating an existing record.. All I see for output is in contact extension init It seems before_insert and before_update are not being called. -- Brad Clements, [EMAIL PROTECTED] (315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
Re: [Sqlalchemy-users] mapper extension before_insert / before_update busted
On 17 Jul 2006 at 21:08, Michael Bayer wrote: its working on this end, i see you are using assign_mapper without a sessioncontext so i guess that means you are on threadlocal, tried that too (which does add its own extension in) but it also works. see if you can attach a test script so i can reproduce. Well, I've created a simple test where all the code is in one file, and it works. When it's split up in different modules, I only see the print statement from the extension __init__() method (which occurs during table compile). Something is seriously screwy. I'm tired and will look at this tomorrow. I wonder if there's some funkiness with module name checking at some point.. I just don't know I will send you some stuff directly. -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] table.drop docs off a bit
svn rev 1770 from http://www.sqlalchemy.org/docs/metadata.myt#metadata_tables Under Creating and Dropping Database Tables Traceback (most recent call last): File touchscreen/dbmanage.py, line 176, in ? main(sys.argv[1:]) File touchscreen/dbmanage.py, line 130, in main table.drop(engine=e) TypeError: drop() got an unexpected keyword argument 'engine' But this is taken directly from the online docs.. Apparently create and drop expect a positional argument, not a keyword. -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] using func.count with session
I'm trying to determine how many records are in a table I'm looking at: http://www.sqlalchemy.org/docs/sqlconstruction.myt#sql_whereclause_functions I tried this: order.priority = \ session.query(Order).select([func.count(Order.c.id)]).execute()[0][0]+1 I get: update_order_accpac_info order.priority = session.query(Order).select([func.count(Order.c.id)]).execute()[0][0]+1 File '/usr/local/src/sqlalchemy/lib/sqlalchemy/orm/query.py', line 226 in select return self.select_whereclause(whereclause=arg, **kwargs) File '/usr/local/src/sqlalchemy/lib/sqlalchemy/orm/query.py', line 231 in select_whereclause statement = self.compile(whereclause, **kwargs) File '/usr/local/src/sqlalchemy/lib/sqlalchemy/orm/query.py', line 360 in compile statement = sql.select([], whereclause, from_obj=from_obj, use_labels=True, **kwargs) File '/usr/local/src/sqlalchemy/lib/sqlalchemy/sql.py', line 53 in select return Select(columns, whereclause = whereclause, from_obj = from_obj, **kwargs) File '/usr/local/src/sqlalchemy/lib/sqlalchemy/sql.py', line 1431 in __init__ self.append_whereclause(whereclause) File '/usr/local/src/sqlalchemy/lib/sqlalchemy/sql.py', line 1487 in append_whereclause self._append_condition('whereclause', whereclause) File '/usr/local/src/sqlalchemy/lib/sqlalchemy/sql.py', line 1493 in _append_condition condition.accept_visitor(self._wherecorrelator) exceptions.AttributeError: 'list' object has no attribute 'accept_visitor' even typingin IPython just session.query(Order).select([func.count(Order.c.id)]) gives the same error. I'll just use connection.execute() I guess.. But I'm curious if this is a docs issue, or I'm doing something wrong. -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
Re: [Sqlalchemy-users] ID generator
On 6 Sep 2006 at 12:17, Michael Bayer wrote: the only working ID generator we have right now is the Sequence object, which obviously is only useable in postgres and oracle, and it is capable of being called in a standalone fashion. Sequence works with Firebird. i.e., I am using this: TWarehouse = Table('Warehouse', metadata, Column('id', Integer, Sequence('w_id'), primary_key=True, nullable = False), Column('name', String(32), nullable = False), ) Sorry if this is not what you're talking about -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
[Sqlalchemy-users] calling create_engine multiple times with same connection string
I thought at one time that calling create_engine multiple times with the same connection string would return the same engine. Now it seems that I get a different engine each time, and hence a different connection pool, so my Paste based application eventually consumes all available database connections (firebird) Also, I think when an engine is garbage collected, it's not closing the connections in the pool. At least in my case, I was only saving the most recently returned value from create_engine on each web request.. and I was getting a new pool every time.. Yet firebird connections never got closed even though those connections were returned to the pool. (checked using echo_pool=True) Are engines referenced somewhere else in sqlalchemy, hence keeping them from being garbage collected? I see the same symptoms using plain or threadlocal strategy. I am using explicit code in wsgi middleware to handle transactions engine = some_user_method connection = engine.connect trans = connection.begin session = create_session(bind_to=connection) .. later I trans.commit() connection.close() discard references to session, trans and connection (I don't keep a reference to the engine) -- So back to the original question, did at one time create_engine return the same engine object for same connection string? -- Brad Clements,[EMAIL PROTECTED](315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users