[sqlalchemy] Composite primary key with nullable columns

2016-01-05 Thread Paul Johnston
Hi, I have a situation where I'm trying to us a composite primary key, where one of the columns can be null. However, when I try to update an object I get the following error: sqlalchemy.orm.exc.FlushError: Can't update table test using NULL for primary key value on column test.id2 Sample

[sqlalchemy] 10 Reasons to love SQLAlchemy

2015-09-04 Thread Paul Johnston
Hi guys, I decided to express my love of SQLAlchemy through a blog post: http://pajhome.org.uk/blog/10_reasons_to_love_sqlalchemy.html Enjoy, Paul -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop

[sqlalchemy] Declarative: defining relationship and column in one line

2015-05-19 Thread Paul Johnston
Hi, Sorry if this is a FAQ, but is it possible to define a relationship and its column all at once. e.g. instead of: type_id = db.Column(db.Integer, db.ForeignKey('linktype.id')) type = db.relationship('LinkType') Something like: type = db.relationship('LinkType',

[sqlalchemy] Joinedload and duplicate relations

2013-07-14 Thread Paul Johnston
Hi, I've just been debugging a slow running query: products = db.Product.query.options(sao.joinedload_all('variations.channels'), sao.joinedload_all('variations.specifics')).all() The second joinedload_all should just have been joinedload. It was causing variations to be included twice in

[sqlalchemy] Recipe for text search across multiple fields

2013-05-31 Thread Paul Johnston
Hi, Often you want to offer the user a text box which will search through multiple fields. If the user is looking at the list of orders, they want a search box that will search: order id, customer name, product names, etc. I'm trying to put together a recipe for this, although it's becoming

Re: [sqlalchemy] Recipe for text search across multiple fields

2013-05-31 Thread Paul Johnston
Hi, That's fixed it! I was so close :-) I was using mapper.order_by, which I'd hoped order_by(None) would cancel. No worries - it works now. This is in tw2.sqla DbListPage now, and I'll be putting updates in as I get round to it. Paul what's the purpose of cls.query.order_by(None) ?

[sqlalchemy] zope.sqlalchemy - commit some objects on failure

2013-01-06 Thread Paul Johnston
Hi, I'm using zope.sqlalchemy in a web application (actually ToscaWidgets not Zope) so each request is wrapped in a transaction. If the request succeeds the transaction is committed; if there is an error it is rolled back. This works great. I have a log table where I log incoming XML to web

Re: [sqlalchemy] Automatic data partitioning using a custom Session class

2012-12-07 Thread Paul Johnston
Hi Mike, we have a recipe that's all about the built in filter which also illustrates how to work around that existing criterion thing: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/PreFilteredQuery Thanks for that - exactly what I needed. I'm still tweaking my app to use this

[sqlalchemy] Automatic data partitioning using a custom Session class

2012-12-06 Thread Paul Johnston
Hi, I hope everyone's keeping well. It's been ages since I've been on the list. I do use SQLAlchemy from time to time, but now it generally works so well, that I don't have any questions to ask! But I would appreciate some thoughts on the approach I've taken with a multi-tennant SaaS web app.

[sqlalchemy] Efficiency of adding to M:M relations

2010-06-30 Thread Paul Johnston
Hi, I hope everyone's well here. It's been some time since I posted. Great to see it up to 0.6, and even more progress on MS-SQL (although I'm now unlikely to be using that). As always, I'm using SQLAlchemy as part of a web app. I have a set of checkboxes, which I'm saving into an M:M relation.

[sqlalchemy] OT: Travel Blog

2008-11-22 Thread Paul Johnston
Hi all, Well, I finally set off on my travels, and it's turned out to be more than I ever dreamed of. If you're interested, I'm keeping a blog here: http://paj28.livejournal.com/ Hope everything's going well with SA. All the best, Paul --~--~-~--~~~---~--~~ You

[sqlalchemy] MSSQL Failing deletes with subquery + schema

2008-10-06 Thread Paul Johnston
Hi, Is there any chance someone can look at ticket 973? http://www.sqlalchemy.org/trac/ticket/973 This is quite important to me, hitting the bug with a production app. I've got a very hacky fix, which just disables the table aliasing, but I don't think that's good enough to commit. I have

[sqlalchemy] Replacement for query.mapper.class_

2008-08-29 Thread Paul Johnston
Hi, Hope everyone is well, not been around for a while. I've noticed one of my apps has broken with an SA upgrade. It was using query.mapper.class_ to determine the class from a query, but query.mapper no longer exists. What's the 0.5 way of doing this? Paul

[sqlalchemy] Moving On

2008-06-24 Thread Paul Johnston
Hi, I've had fun over the last 18 months doing odd bits of work on SQLAlchemy. It works pretty damn well on MSSQL now, although I never did quite get all the unit tests nailed. It's been great seeing the library continue to evolve, and particularly satisfying to see things I've started (e.g.

[sqlalchemy] Re: sqlite PK autoincrement not working when you do a composite PK?

2008-06-13 Thread Paul Johnston
Hi, I don't think that is a very workable strategy in the long run :( There are far to many bogus restrictions in some databases, e.g. Oracle, for any meaningful program to be written to work on all platforms w/o support/wrapping/hiding of ugly details by SA. This is often a difficulty for

[sqlalchemy] Re: Troublesome relation

2008-06-10 Thread Paul Johnston
Hi, VulnResDesc.mapper.add_property('rawvulns', sao.relation(VulnRes.mapper, primaryjoin = sa.and_(VulnRes.targetid == VulnResDesc.targetid, VulnMap.vulndescid == VulnResDesc.id, VulnMap.tool == VulnRes.tool,

[sqlalchemy] Re: Troublesome relation

2008-06-10 Thread Paul Johnston
Hi, I still don't quite understand this I'm afraid, I though there were more columns involved - VulnResDesc.id, VulnRes.tool, VulnRes.toolvulnid. So you know, this isn't urgent now. I've rewritten the mapper property as a property on my class, and that works straight off, without any voodoo.

[sqlalchemy] Re: How to calculate the size of the Oracle and PostgreSQL schema !!!!!

2008-06-10 Thread Paul Johnston
Hi, My development team and me are working in a application to migrate Oracle databases to PostgreSQL databases, and we need this information to do this. I've done successful migrations using autocode, http://code.google.com/p/sqlautocode/ The procedure, roughly is: 1) Use autocode to

[sqlalchemy] Troublesome relation

2008-06-09 Thread Paul Johnston
Hi, I have had the following relation working ok for some time, but a recent update of SQLAlchemy means it's now asking for a remote_side argument. I'm really not too sure what too put in there - I've never really understood that parameter, or foreign_keys.

[sqlalchemy] Re: Optimizing a slow query

2008-06-08 Thread Paul Johnston
Hi, create index viewforum on forum_post (topic_id, id); You probably want: create index forum_post_topic_id on forum_post (topic_id); Paul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group.

[sqlalchemy] Re: Optimizing a slow query

2008-06-08 Thread Paul Johnston
Hi, create index forum_post_topic_id on forum_post (topic_id); are you sure? A key on topic_id and id makes my query much faster for low offsets, while without it the query takes even for low offsets 10 seconds. I didn't follow the beginning of this thread, so I'm not sure exactly

[sqlalchemy] Re: SqlAlchemy and Stored Procedures with variables

2008-05-21 Thread Paul Johnston
Hi, I thought the original impetus for scope_identity was not multiple execution contexts, but rather things being fouled up for some users where they had nested INSERTs being done via a trigger on the mapped table, and the brain-dead SELECT @@identity_insert wasn't able to pluck out the

[sqlalchemy] Re: SqlAlchemy and Stored Procedures with variables

2008-05-20 Thread Paul Johnston
Hi, The SQL works in our SQL analyzer with or without the named parameter and with the semicolon. We tried it the way you mentioned too, using positional parameters, and got the same error. I apologize for forgetting to mention that in my first post. Dunno if this is related, but

[sqlalchemy] Re: MSSQL dislikes schema= on table.create()

2008-05-19 Thread Paul Johnston
Hi, The specified schema name queer either does not exist or you do not have permi ssion to use it. This isn't an SQLAlchemy or DBAPI issue - you just need to create the schema with the correct permissions. Paul --~--~-~--~~~---~--~~ You received this message

[sqlalchemy] Re: MSSQL dislikes schema= on table.create()

2008-05-19 Thread Paul Johnston
Hi, So now I'm of two minds about which module to use and if I should use a schema or not for these porposes. I'm using PyODBC and schemas, and things work just fine for me. Ok, some error messages aren't quite there, but it works well enough for me. Paul

[sqlalchemy] Re: Query Threading Issue

2008-05-06 Thread Paul Johnston
Hi Mike, ive thought about this, and the Query is not in fact tied very hard to a partcular Session (or at all). I think it would be workable for us to add a using_session() method to it, i.e.: The original workaround you suggested of using a callable works fine for now. A

[sqlalchemy] Re: arbitrary information for sa objects

2008-05-04 Thread Paul Johnston
Hi, http://www.sqlalchemy.org/docs/04/sqlalchemy_schema.html#docstrings_sqlalchemy.schema_Table shows info as a parameter in the kwargs to a table. So it does, so it's tables and columns. The column info setting is in the same page as you sent across, just a bit further up. What other

[sqlalchemy] Query Threading Issue

2008-05-04 Thread Paul Johnston
Hi, I'm writing a ToscaWidget to do a kind of data grid. The way I've designed it so far, you pass an SA query object to the Widget when it's created. Then, each time it's displayed, it applies a few extra filters to the query and fetches the results. I'm using scoped sessions, and the query ends

[sqlalchemy] Re: arbitrary information for sa objects

2008-05-03 Thread Paul Johnston
Alex, The info bucket is available just on columns at the moment, and it is a supported feature. I think we're open to adding it to other types, such as tables, if someone has a requirement. My desire for this was exactly the same as yours - the SA model serving as the authoritative master

[sqlalchemy] Re: mssql, pyodbc and rowcount

2008-05-01 Thread Paul Johnston
Hi, meta.Session.execute(meta.metadata.tables.get(table).select()).rowcount -1 Can anybody explain what I have to do (if possible at all) to get the correct number of rows in my cursor? I don't think you can, short of reading all the results. The reason being that pyodbc streams them from

[sqlalchemy] Re: cant update mssql table

2008-04-28 Thread Paul Johnston
Hi, a table in a mssql db with a uniqueidentifier field as primary key and an integer field as identity,i am able to insert a row into the table but not update it Can you send the code you're using, and the error you are getting? I think this is an area we haven't particularly covered so far.

[sqlalchemy] Re: ODBC Connection is busy error

2008-04-24 Thread Paul Johnston
Hi, Since our system went live we have been getting more more errors like this: DBAPIError: (Error) ('HY000', '[HY000] [Microsoft][SQL Native Client]Connection is busy with results for another command (0)') u'SELECT ...snip valid SQL string...endsnip I've seen this error too, in fact some

[sqlalchemy] Re: Extension proposal

2008-04-15 Thread Paul Johnston
Hi, the function so far seems pretty use-case specific. (only works in one direction, is hardcoded to the obj.mapper convention, sort of Ok, fair enough. It looks like Elixir will accept this, and Jonathan also made the observation that my approach is one-way. For the time being, I've updated

[sqlalchemy] Extension proposal

2008-04-14 Thread Paul Johnston
Hi, I have a utility function that I keep using again and again in my web apps. It takes a nested hash/list structure, something like: data = \ { *'id'*: 123, *'name'*: *'Example customer'*, *'contacts'*: [ {*'id'*:12, name=*'Alice'*} {*'id'*:23, name=*'Bob'*} ] } And it takes

[sqlalchemy] Re: Extension proposal

2008-04-14 Thread Paul Johnston
Hi, In my case, the data is coming from FormEncode. I guess it could come from JSON, but that would be JSON client to server, which is not the usual way round. The proposal is for a standalone function, I'm thinking you'd do something like: from sqlalchemy.ext.proc_hash import proc_hash ...

[sqlalchemy] Re: SQLAlchemy questions

2008-04-14 Thread Paul Johnston
Hi, I think you'll do well to switch to an open library, I certainly found it worthwhile when I made a similar switch 18 months ago. And that's despite getting side-tracked making SA support MSSQL more completely :-) On you specific points: 1. Be able to call custom functions when a field is

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-04-01 Thread Paul Johnston
Hi Lukasz, Under: http://www.sqlalchemy.org/docs/04/documentation.html#dbengine_establishing after: # oracle will feed host/port/SID into cx_oracle.makedsn oracle_db = create_engine('oracle://scott:[EMAIL PROTECTED]:1521/sidname') It's great to see you getting MSSQL to work on Unix. I know

[sqlalchemy] Re: MSSQL, pyodbc linux

2008-03-25 Thread Paul Johnston
Hi, eng = sqlalchemy.create_engine (mssql:///?dsn=mydsn,UID=myusername,PWD=mypass,module=pyodbc) Try this: eng = sqlalchemy.create_engine (mssql://myusername:mypass@/?dsn=mydsn,module=pyodbc) Paul --~--~-~--~~~---~--~~ You received this message because you are

[sqlalchemy] Re: Suggestions for setup.py

2008-02-17 Thread Paul Johnston
Hi, h im not sure every DBAPI can get installed through easy_install tho. pyscopg2 comes to mind. Similarly you can't easy_install pyodbc at the moment. I was thinking that doing this would be motivation to do the work to make those packages easy_install'able. Paul

[sqlalchemy] Suggestions for setup.py

2008-02-15 Thread Paul Johnston
Hi, I've noticed that setuptools supports optional dependencies http://peak.telecommunity.com/DevCenter/setuptools#declaring-extras-optional-features-with-their-own-dependencies Would it be worth adding one of these for each database SA supports? You could then do easy_install sqlalchemy mssql

[sqlalchemy] Re: executing stored procedure which returns rows

2008-02-13 Thread Paul Johnston
John, I am using unixodbc-2.2.11 as packaged by Ubuntu 7.10 (gutsy) with That sounds very promising, I have been meaning to have a go at this for a while. Can you do me a favor and run the unit tests using your current setup? Run alltests.py and append text_as_varchar=1 to the dburi (a

[sqlalchemy] MSSQL Sprint

2008-02-12 Thread Paul Johnston
Hi, Would anyone like to join me in doing a one day sprint on MSSQL support in SQLAlchemy? (Rick - hope you can find some time) I feel we're at the point now where the last few niggles could be ironed out quite quickly. I've just lost steam a bit doing this on my own. The main points would

[sqlalchemy] Re: schema changes

2008-02-12 Thread Paul Johnston
Hi, ...and what happens if these methods are called and the tables already exist? With metadata.create_all, it only creates ones that don't exist. table.create() will error, or if you use the checkfirst option, will do nothing. What if they exist but don't match the spec that SA has

[sqlalchemy] Re: schema changes

2008-02-08 Thread Paul Johnston
Hi Chris, What happens when the schema expected by the mappers doesn't match up to the schema in the database? If the SQLAlchemy table definitions don't match the database, you will usually get SQL errors when you try to use them. The TurboGears admin tool can tell you the differences between

[sqlalchemy] Re: InvalidRequestError

2008-02-08 Thread Paul Johnston
Hi, I do a session.clear(), all time, after of session.save_or_update([obj]) Can this be the problem? That is almost certainly your problem. Try removing the session.clear() and see if it then works. When is advisable do a session.clear() ? When you're done with a batch of processing.

[sqlalchemy] Re: Connecting to MSSQL with a System DSN on Windows

2008-01-17 Thread Paul Johnston
Hi, For some reason it didn't work for me (sqlalchemy 0.4.2p3). I tried mssql://?dsn=MyDSN, and also mssql://?DSN=MyDSN. Oh well. Sorry, it's mssql:///?dsn=mydsn This definitely works, just tested it eng = sqlalchemy.create_engine('mssql:///?dsn=bob') eng.execute('select 1')

[sqlalchemy] Re: Connecting to MSSQL with a System DSN on Windows

2008-01-16 Thread Paul Johnston
Hi, 'mssql://DSN=MyDSN'. How can I get this to work without specifying You were nearly there... mssql://?dsn=mydsn Paul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group,

[sqlalchemy] Re: connect sql server

2008-01-13 Thread Paul Johnston
Hi, How can I connect to sql server with windows authentication using sqlalchemy? Using pymssql I haven't find a way. You have to use adodbapi or pyodbc - just specify no username/password and it just works. I don't think it's possible with pymssql. Paul

[sqlalchemy] Re: MSSQL and LIMIT/OFFSET

2008-01-10 Thread Paul Johnston
Hi, adding row_number will render a distinct clause useless... Actually, this isn't a problem, as the distinct goes in an inner query, and the row_number is only in the outer query. I did have this mostly working, just need a final push to get it finished and committed. Paul

[sqlalchemy] Issue with flush()

2008-01-08 Thread Paul Johnston
Hi, Having just upgraded to the latest svn, I'm now getting the traceback below. It looks like it's related to the attribute tracking changes. This is coming from a fairly large program, but if it helps, I can extract a minimum test case. c:\sqlalchemy\lib\sqlalchemy\engine\base.py:1439:

[sqlalchemy] Re: migrating to 0.4: Parent instance is not bound

2008-01-08 Thread Paul Johnston
Hi, sqlalchemy.exceptions.InvalidRequestError: Parent instance class ' doupy.model.objects.JobPosting' is not bound to a Session, and no contextual session is established; lazy load operation of attribute 'author' cannot proceed. Not 100% sure without seeing your model, but you probably want

[sqlalchemy] Re: save_or_update and composit Primary Keys... MSSQL / pyodbc issue ?

2007-12-10 Thread Paul Johnston
Hi, /me faces toward UK, where it's about midnight right now... /me yells HEY PAUL!! YOU WATCHING THIS THREAD?? Ok, you got my attention :-) Not at my best right now after being out drinking, but hey... After a little tweak to the code (removing autoload=True, adding metadata.create_all()

[sqlalchemy] Re: Design: mapped objects everywhere?

2007-12-07 Thread Paul Johnston
Hi, A Sample may be created by the web application or fetched from the database. Later on, it may be disposed of, edited or checked back into the db. On the other hand, the requirements and coding of both classes are kinda different, and I find myself changing the properties of the

[sqlalchemy] Re: Representation of boolean logic in a database

2007-12-06 Thread Paul Johnston
Hi, My problem is beeing able to represent and store relations between options and contents tables in a normalized way. I'd probably just store the relationship as a string. Do you have any particular querying requirements? Sometimes pragmatism beats elegance. Paul

[sqlalchemy] Re: SA 0.4.1 and MS-SQL problem at create time

2007-12-06 Thread Paul Johnston
Hi, It seems that the mssql backend use a 'foreign_key' attribute on Column which does not exist anymore. Yes, it's now foreign_keys. This is fixed in the svn trunk. I still need to sort out a way to have MSSQL unit tests run periodically, so we can pick up this kind of issue before

[sqlalchemy] MSSQL and LIMIT/OFFSET

2007-11-26 Thread Paul Johnston
Hi, Can someone (Mike?) give me a hand with this, I've hit the limits of my understanding of the query compiler. The patch I've done on #638 (mostly copied from Oracle) creates a subquery with row_number if there is an OFFSET. It aliases the query, because MSSQL is funny about that, and it

[sqlalchemy] Re: unicode support for MSSQL

2007-11-25 Thread Paul Johnston
Hi Florent, Just realised we'd gone quiet on this thread... humm What bothers me is that I already get this comportement when running my query program from a Linux host (using pyodbc same version) but need the above mentioned patch on a windows host so there is definitely a different behavior.

[sqlalchemy] Re: pyodbc and inserts... again

2007-11-25 Thread Paul Johnston
Hi, I've just noticed a remaining problem with the pyodbc/inserts with triggers/scope_identity()/set nocount on/nextset() thing ;-) (it's still a workaround if I understand correctly?) scope_identity is expected to be a permanent solution. The set nocount on is a bit of a hack and will

[sqlalchemy] Multiple inserts and last_inserted_ids

2007-11-25 Thread Paul Johnston
Hi, I just realised, MSSQL is not returning last_inserted_ids correctly when an insert is done with multiple sets of params for a single statement. I don't think this is particularly a problem, just wanted to check what the intention is. Paul

[sqlalchemy] Re: FYI: SQLAutocode 0.4.1 and 0.5 released

2007-11-13 Thread Paul Johnston
Hi, Could you perhaps explain the advantages/differences to autoload=True or perhaps SqlSoup? To me, it's quite a different approach to managing your database schema. Using autoload or sqlsoup, the database holds the master definition of the schema, and your program automatically loads

[sqlalchemy] Re: Deprecation error raised for query on singly inherited table query ?

2007-11-11 Thread Paul Johnston
Hi, The following is a stripped down use case that I have, where I use single table inheritance and run a query.first(), however I get a deprecation warning and I was wondering why ?? A minor bug, an instance of SA internally using the deprecated syntax. Fixed in r3766. Paul

[sqlalchemy] Re: unicode support for MSSQL

2007-11-08 Thread Paul Johnston
Hi, I have isolated the problem a little bit more: my column is defined in the MSSQL server as a user defined type which is based on VARCHAR. Ok, so in this case you'd like SA to return a python unicode object when a VARCHAR is fetched, by decoding using the database's encoding? While I

[sqlalchemy] Re: Can I have an integer primary keys that is not a sequence?

2007-11-06 Thread Paul Johnston
Hi, Is there a way to tell SQLAlchemy to create an ordinary integer primary key, without any associated sequence? Sure... autoincrement=False Paul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy

[sqlalchemy] Re: unicode support for MSSQL

2007-11-05 Thread Paul Johnston
Hi, I have 10 different instances the each have their own collation names (latin1, greek, russian...) I have a master database that references all thos instances + their collation names. I use this master database to create the engines to the different dbs. I would like to be able to just pass

[sqlalchemy] Re: access mapped object attributes

2007-11-05 Thread Paul Johnston
Hi, Given a Message object, do I have a way to retrieve all the attributes that result from the database mapping? Try this: for col in Message.c: ... Paul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

[sqlalchemy] Re: Add arbitrary information to some classes

2007-11-05 Thread Paul Johnston
Hi, sorry, i havent been following. two++ dicts ?! this is getting out of hand. if we have to have any dicts at all, it would be just one dict. and also, it should be proxied through a property so that if you dont access it, its never even created. I have just put a proposed

[sqlalchemy] Re: column and table functions from sqlalchemy.sql

2007-11-05 Thread Paul Johnston
Hi, Just noticed that from sqlalchemy import * imports all functions from sqlalchemy.sql.expression, except column and table - is this by intent or have these only be forgotten? It's to prevent confusion between column and Column - which are very different! Paul

[sqlalchemy] Re: unicode support for MSSQL

2007-11-03 Thread Paul Johnston
Florent, I just added ticket #839 to the trac and attached a patch that enables unicode conversion for MSSQL dialects. I tested it with pyodbc but it should work the same with the other dialects. What's the benefit of doing this? I've found that you usually want to pass python unicode

[sqlalchemy] Re: How to get list of relations

2007-10-31 Thread Paul Johnston
Hi, You are missing a compile call before you can iterate properties. try adding: Ah, that is indeed the problem. With that in place, iterate_properties does very nearly what I need. The only problem is that I need to get the name of the relation as well. For now, the following works: [(a,b)

[sqlalchemy] Re: Add arbitrary information to some classes

2007-10-31 Thread Paul Johnston
Hi, Ah sure, so it's to be a namespace for namespaces, a shared dict() parking lot. Got it. How about having two dicts? One is purely for user data, libraries and such never touch it. I suggest userdata. The other is for use in extensions and stuff, say extdata. Paul

[sqlalchemy] Re: How to get list of relations

2007-10-30 Thread Paul Johnston
Mike, use mapper.get_property(name) and mapper.iterate_properties(). I've considered removing properties as a public accessor since it serves no useful purpose. This doesn't work for me - the following code outputs: [Column('id', Integer(), primary_key=True, nullable=False)] [Column('val',

[sqlalchemy] Re: How to get list of relations

2007-10-30 Thread Paul Johnston
Hi, use mapper.get_property(name) and mapper.iterate_properties (). I've considered removing properties as a public accessor since it serves no useful purpose. Ok, I found a hacky way that does what I need: [(n, getattr(obj, n)) for n in dir(obj) if isinstance(getattr(obj, n),

[sqlalchemy] Re: How to get list of relations

2007-10-30 Thread Paul Johnston
Hi, Ok, I found a hacky way that does what I need: [(n, getattr(obj, n)) for n in dir(obj) if isinstance(getattr(obj, n), sqlalchemy.orm.attributes.InstrumentedAttribute)] Ooops, not quite what I need. How do I go from a CollectionAttributeImpl to a mapper? Paul

[sqlalchemy] Re: SQLalchemy coding style

2007-10-29 Thread Paul Johnston
Hi, I have a python file for all the table and class definitions (model.py). In that I do from sqlalchemy import *, and that's ok as in that one file I know not to use names like Table. In my other python files I just import classes from model.py, and specific bits of sqlalchemy. Ok,

[sqlalchemy] How to get list of relations

2007-10-29 Thread Paul Johnston
Hi, How do I get a list of the relations a mapper has? I've been using mapper.properties, but have just realised this doesn't pick up backrefs. Any ideas? Thanks, Paul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

[sqlalchemy] Re: Two MSSQL databases on one engine?

2007-10-25 Thread Paul Johnston
Hi, Do have to define two engines to access two databases on the same database server? With MSSQL, at the moment you do. People have suggested changes to workaround this (using dbname.schema.table), but nothing has been implemented as yet. Paul

[sqlalchemy] Re: SA (4.0) mssql table creation problems. No Python Errors?

2007-10-24 Thread Paul Johnston
Hi, Thanks for the help. I am still having those intermittent problems. I tried using just pyodbc, but the symptoms were the same. I tried a new machine, Windows 2003 Server, and installed SQL Server 2005 (SP2), Python, EZTools(py), Win32com(py), pyodbc(py), sqla(py), I've used MSSQL through

[sqlalchemy] Re: RLIKE, REGEXP

2007-10-21 Thread Paul Johnston
Hi, Resource.select_by( foo=bar ) Untested, but I reckon this will work: Resource.query.filter(Resource.foo.op('rlike')('bar')) Paul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post

[sqlalchemy] Re: Connecting to a Microsoft Access Database

2007-10-19 Thread Paul Johnston
Hi, access:///VMCPDB.mdb Three slashes! The hostname is empty. And you want the full path to the .mdb file. Paul On 10/18/07, Eddie [EMAIL PROTECTED] wrote: Latest Version still gives me problems still in the same engine = create_engine('access://VMCPDB') line. Debug looks like the

[sqlalchemy] Re: Storing DB engine in session

2007-10-17 Thread Paul Johnston
Hi, Here's how it should work: every time the user logs in, SA creates a new engine with his log/pass or uses the one that was already opened and then uses it. Unless something has changed recently, this pattern is not particularly supported. Still, you could probably get it working with

[sqlalchemy] Re: Connecting to a Microsoft Access Database

2007-10-16 Thread Paul Johnston
Hi, Thanks for the help. Looks like I'm still stuck though. Use the latest SVN version of SA 0.4, where I've fixed this issue. You'll need to do something like: svn checkout http://svn.sqlalchemy.org/sqlalchemy/trunk sqlalchemy cd sqlalchemy setup.py develop Paul

[sqlalchemy] Re: FYI: AutoCode moved to a new repository

2007-10-12 Thread Paul Johnston
Hi, I don't say that everything should be integrated, just the reflection part (if at all useful in SA0.4) and the repr methods of the corresponding objects (*_repr in formatter.py) which should IMHO replace the current repr methods. That sounds good. One consideration is that autocode repr

[sqlalchemy] Re: FYI: AutoCode moved to a new repository

2007-10-12 Thread Paul Johnston
Hi, BTW, with SA 0.4, this script should be able to work with no database-specific hacks at all. If you're interesting in implementing this, I can explain more. Would be nice to hear more details about this. With 0.4, dialects have a table_names() method that will do the job of

[sqlalchemy] Re: Connecting to a Microsoft Access Database

2007-10-12 Thread Paul Johnston
Hi, I am very sorry for asking this question, but I was wondering if anyone could give me a short step by step process as to how to access a Microsoft Access Database using SQLAlchemy. Access support is experimental. Use the lastest 0.4 trunk, as I've committed a few fixes just now.

[sqlalchemy] Re: FYI: AutoCode moved to a new repository

2007-10-11 Thread Paul Johnston
Hi, It's really good to see this script progressing. BTW, with SA 0.4, this script should be able to work with no database-specific hacks at all. If you're interesting in implementing this, I can explain more. Paul --~--~-~--~~~---~--~~ You received this message

[sqlalchemy] Re: Can't insert records into a MS SQL database

2007-10-07 Thread Paul Johnston
Hi, Try adding autoincrement=False to the t_year column. why would this fix the issue exactly ? Fair question. The explanation is a bit convoluted, not as nice and simple as the fix. MSSQL's equivalent of SERIAL/autoincrement is an identity flag on a column. To insert an explicit

[sqlalchemy] Re: Can't insert records into a MS SQL database

2007-10-06 Thread Paul Johnston
Hi, ppi = Table('ttfvbs061100', metadata, Column('t_year', Integer, primary_key=True), Column('t_dimx', String(), primary_key=True), Column('t_ceco', String(), primary_key=True), autoload = True) Try adding autoincrement=False to the t_year

[sqlalchemy] Re: Supporting sybase backend through mx.ODBC driver

2007-09-30 Thread Paul Johnston
Hi, I was wondering if there is any development effort going on to support a sybase backend for sqlalchemy based on the mx.ODBC drivers from egenix (google didn't find anything and there was no relevant thread on this list) ? Are you hard set on mxODBC? PyODBC seems to be a good free

[sqlalchemy] Re: Built-in escape function?

2007-09-21 Thread Paul Johnston
Hi, It doesn't, and that would be a reasonable addition. I'm also thinking that startswith, endswith and contains should probably do the escaping by default. If you create a ticket I'll look at it sometime, although not for a couple of weeks (I'm on holiday, woo :-) Paul On 9/21/07, Felix

[sqlalchemy] Re: MSSQL connection url format?

2007-09-19 Thread Paul Johnston
Hi, Should the hostname be the IP of the server or SQL Server's host\instance combination? Both work ok for me. Isn't the port normally 1433? Yup 2. I saw an archived email that said there was better support for MSSQL in 0.3 than in 0.4. Is that still the case? Support in 0.4 is

[sqlalchemy] Re: Feature suggestion: Description attribute in Tables/Columns

2007-09-19 Thread Paul Johnston
Hi, For my documentation, it is very handy to gather the table definitions directly from my SQLAlchemy-based python code - that's relatively easy, I This would be useful for me too, and it would be good to have hooks to store arbitrary information. I'd be using this as hints for a form

[sqlalchemy] Re: Weak Referencing Session

2007-09-12 Thread Paul Johnston
Hi, that the identity map within the Session again becomes weak referencing, the way it used to be back in 0.2 and part of 0.3. +0 from me. It sounds like a sensible change, but I only use short-lived sessions in web apps, so it makes little difference to me. Paul

[sqlalchemy] Re: sqlalchemy with turbogears and assign_mapper: select

2007-09-07 Thread Paul Johnston
Hi, And if I wanted to select a year and group by year? select User.Year from User group by User.Year db.execute(select([User.Year]) ??? Have a look at http://www.sqlalchemy.org/docs/04/sqlexpression.html Paul --~--~-~--~~~---~--~~ You received this message

[sqlalchemy] Re: sqlalchemy with turbogears and assign_mapper: select

2007-09-05 Thread Paul Johnston
Hi, I am using turbogears with sqlalchemy and assign_mapper. How do I select one column only when doing a select statement? Can I ask why you want to do that? Unless you're really speed critical, selecting them all isn't too bad. But, if you're set on this, there are two approaches: 1)

[sqlalchemy] Re: Elixir performance

2007-09-05 Thread Paul Johnston
Hi, data. I did some benchmarks a while back to see how everything stacked up as I was wondering if I was doing everything the hard way (in C++) instead of using SqlAlchemy, etc. TurboEntity is the same as Great work Eric. I am quite surprised at the results. I would have thought

[sqlalchemy] Re: Testing for validity of a Connection

2007-08-31 Thread Paul Johnston
Hi, What it doesn't handle is if the database server is restarted. That doesn't happen very often with reliable database servers nowadays but it is possible. Yes, this is something of a problem for long-running apps that used pooled database connections. I did some work with Mike a few

[sqlalchemy] Re: Best way to handle in()

2007-08-28 Thread Paul Johnston
Hi, foo = session.query(MainTable).filter_by(customer='CUSTNAME') foo = foo.filter(ChildTable.c.othercolumn.in_('bar', 'baz', 'qux')) You need to do the join; pass the name of the relation (not the target table) to join: foo =

[sqlalchemy] Re: interface error with Decimal(0) in where clause

2007-08-24 Thread Paul Johnston
Hi, firebird which is the only other database engine supported by SA that is embeddable in a python application without the need of and external server. There is one other option, on Windows, the SA 0.4 beta supports Microsoft Access. I believe it works on all Windows systems (i.e. not

[sqlalchemy] Re: between_op() error with property expressions: is this a bug?

2007-08-23 Thread Paul Johnston
Hi, sounds like a bug. for now, call it from the Column object: MappedClass.c.age.between(1,2) (that should work). There seems to be a bug in sql/operators.py - between only has two arguments, not three. I've hit this as well. Paul --~--~-~--~~~---~--~~

[sqlalchemy] Re: Using 0.4 in anger

2007-08-19 Thread Paul Johnston
Hi, Couple more things: 1) When specifying foreign_keys manually on a relation, you have to use table.c.column; table.column doesn't work. 2) I used to be able to do obj.delete() but now obj.query.delete() isn't available. You can make whatever changes needed to ActiveMapper, but keep in

  1   2   >