[sqlalchemy] family tree
Hello, I'd like to build something like a family tree where descendants, mother and father are properties (of each person-object) defined by a mapper. When these properties are accessed, one (in case of mother or father) new person-object schould be loaded, or a list of person-objects (in case of descendants). Each row in the table presents one persons, who knows its mother_id and its father_id. That is not really a normal tree structure because a person-object may not only have many descendants but also has more than one ancester (mother and father). Is there a way to build a mapper that can map these relationships? thanks for help, jawa --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: family tree
You might want to have a look at Adjacency List Relationships: http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_relatio... Thanks for your reply. But that is what I already looked at and tried to use, but it didn't work. I think the problem is, that there are two columns (mother and father) with a foreign-key that reference the same table. sqlalchemie doesn't seem to know, which one to use for which property (well, thats quite consequential, as I didn't tell it, which foreign- key belongs to which property...). I will specify my question a little: is there a way to allocate properties -manually- to certain foreign-key-columns? I hope now my problem has become a little clearer greetz, jawa --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: family tree
Ok, I just read about the relation option foreign_keys... I think, that might be the 'magic' of the whole thing^^ sry, for bothering you, jawa --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] aliased tables
Hi all, how can i know the correct name of a table compiled into qry that SA has automatically aliased? for example: a join b join c join d.. sqlalchemy has created something like select blabla from a AS anon_b406 join. when i try to put into an order by a obviously the qry goes wrong. invalid reference to FROM-clause entry for table a Thank's Glauco -- ++ Glauco Uri - Programmatore glauco(at)allevatori.com Sfera Carta Software(R) [EMAIL PROTECTED] Via Bazzanese,69 Casalecchio di Reno(BO) - Tel. 051591054 ++ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: family tree
thanks, I'll try that, if the relation option foreign_keys didn't do it. I'd like to get normal properties with normal getter and setter or append methods. I use sqlalchemy because I don't want to write all these methods by myself ;) greetz, jawa --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: family tree
On 9/27/07, jawarumnur [EMAIL PROTECTED] wrote: thanks, I'll try that, if the relation option foreign_keys didn't do it. I think you don't need foreign_keys. The docs for foreign_keys states that it should be used in conjuction with primaryjoin only if SA can not guess the FK from the join condition alone. In this case we're only joining on defined ForeignKey(..) fields so SA should have no problem figuring it out. I'd like to get normal properties with normal getter and setter or append methods. I use sqlalchemy because I don't want to write all these methods by myself ;) What do you mean normal? You have normal getters and setters for the properties father and mother. If you want a magic property for children that you can, say, append stuff to - I don't think SA will help you much since the relationship to the child depends strictly on if you are to be it's father or mother (which depends on the parent's gender). SA doesn't do that kind of logic. Besides, it's quite simple to do by hand. If you want a proper collection for children that you can append to, a small helper class will solve that issue. Arnar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: family tree
mh, you're right. I'm not yet very familiar with sqlalchemy since this is my first try. I thought about a WHERE clause additional to the join condition to differentiate the genders but probably that won't work either. I'll try to use python properties then, I think. thanks, jawa --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: aliased tables
Hi Glauco On 9/27/07, Glauco [EMAIL PROTECTED] wrote: Hi all, how can i know the correct name of a table compiled into qry that SA has automatically aliased? for example: a join b join c join d.. sqlalchemy has created something like select blabla from a AS anon_b406 join. when i try to put into an order by a obviously the qry goes wrong. invalid reference to FROM-clause entry for table a Does your question has any relation with the patch that allows ordering or related objects's attributes ? ;) If so, I think I know what you are doing wrong... you must use Query's .join() or .outerjoin() method. Like that: session.query(ObjectA).join('property_b').order_by(ObjectB.c.foobar) Where 'foobar' maps to the column from B table which you want to use to sort your data... Thank's Glauco HTH.. Roger --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: aliased tables
Roger Demetrescu ha scritto: Hi Glauco On 9/27/07, Glauco [EMAIL PROTECTED] wrote: Hi all, how can i know the correct name of a table compiled into qry that SA has automatically aliased? for example: a join b join c join d.. sqlalchemy has created something like select blabla from a AS anon_b406 join. when i try to put into an order by a obviously the qry goes wrong. invalid reference to FROM-clause entry for table a Does your question has any relation with the patch that allows ordering or related objects's attributes ? ;) no no Roger, i will install next days... If so, I think I know what you are doing wrong... you must use Query's .join() or .outerjoin() method. Like that: session.query(ObjectA).join('property_b').order_by(ObjectB.c.foobar) Where 'foobar' maps to the column from B table which you want to use to sort your data... This is correct Roger, but my problem is when in this example SA compile the qry using alias select ... form table_a as alias1. table_b as alias2... order by table_a.column1 in this case the qry is wrong because the order by is incorrect. take a look *sqlalchemy.exceptions.SQLError: ('(ProgrammingError) missing FROM-clause entry for table azienda\n', SELECT unita_aziendale.id_anagrafica AS unita_aziendale_id_anagrafica, unita_aziendale.bdn_data_ultima_modifica AS unita_aziendale_bdn_data_ultima_modifica, unita_aziendale.bdn_specie AS unita_aziendale_bdn_specie, unita_aziendale.ts_ultima_modifica AS unita_aziendale_ts_ultima_modifica, ****unita_aziendale.id_precedente AS unita_aziendale_id_precedente, ****unita_aziendale.id AS unita_aziendale_id, CUT ****anon_b406.data_aggiornamento AS anon_b406_data_aggiornamento, unita_aziendale.bdn_flag_carne_latte AS unita_aziendale_bdn_flag_carne_latte FROM produzione, unita_aziendale LEFT OUTER JOIN anagrafica AS anon_b3be ON anon_b3be.id = unita_aziendale.id_anagrafica LEFT OUTER JOIN scheda_totali AS anon_b406 ON unita_aziendale.id = anon_b406.id_unita_aziendale WHERE SOME CONDITION ORDER BY azienda.id_asl ASC, anon_b3be.id, anon_b406.id_unita_aziendale' Glauco * -- ++ Glauco Uri - Programmatore glauco(at)allevatori.com Sfera Carta Software(R) [EMAIL PROTECTED] Via Bazzanese,69 Casalecchio di Reno(BO) - Tel. 051591054 ++ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Bug in SA-0.4b6
Hi, I have problem here with SA-0.4b6: I created an own table that inherits from sqlalchemy.Table like this: class MyTable(sqlalchemy.Table): pass When I now create tables using this class (e.g. mytable = MyTable(...)), the tables are not created via metadata.create_all(). The log files denotes it, it has the following lines: INFO sqlalchemy.engine.base.Engine 0x..10 PRAGMA table_info(mytable) INFO sqlalchemy.engine.base.Engine.0x..10 () But the following, important lines, are missing (they are there when mytable's class is sqlalchemy.Table): INFO sqlalchemy.engine.base.Engine.0x..10 CREATE TABLE mytable ( myid . ) INFO sqlalchemy.engine.base.Engine.0x..10 None INFO sqlalchemy.engine.base.Engine.0x..10 COMMIT With SA-3.10 I don't have this problem. So, I assume, this is a bug? Best Regards, Hermann -- [EMAIL PROTECTED] GPG key ID: 299893C7 (on keyservers) FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: aliased tables
On 9/27/07, Glauco [EMAIL PROTECTED] wrote: If so, I think I know what you are doing wrong... you must use Query's .join() or .outerjoin() method. Like that: session.query(ObjectA).join('property_b').order_by(ObjectB.c.foobar) Where 'foobar' maps to the column from B table which you want to use to sort your data... This is correct Roger, but my problem is when in this example SA compile the qry using alias select ... form table_a as alias1. table_b as alias2... order by table_a.column1 in this case the qry is wrong because the order by is incorrect. take a look SNIP Glauco, can you send a small test script reproducing the error ? I'll gladly take a look at that... Cheers, Roger --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Bug in SA-0.4b6
On Sep 27, 2007, at 10:07 AM, Hermann Himmelbauer wrote: With SA-3.10 I don't have this problem. So, I assume, this is a bug? I woudlnt consider this a bug since subclassing of tables was never something supported. however, to make it work do this: class MyTable(Table): __visit_name__ = 'table' --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: aliased tables
Glauco, can you send a small test script reproducing the error ? I'll gladly take a look at that... Cheers, Roger Yes... this is the example session.query( UnitaAziendale ).order_by(Anagrafica.c.nome) (ProgrammingError) invalid reference to FROM-clause entry for table anagrafica *HINT: Perhaps you meant to reference the table alias anon_b3be.* 'SELECT unita_aziendale.ts_ultima_modifica AS unita_aziendale_ts_ultima_modifica, unita_aziendale.id AS unita_aziendale_id, unita_aziendale.id_anagrafica AS unita_aziendale_id_anagrafica, unita_aziendale.id_operatore AS unita_aziendale_id_operatore, unita_aziendale.data_inizio AS unita_aziendale_data_inizio, unita_aziendale.bdn_data_ultima_modifica AS unita_aziendale_bdn_data_ultima_modifica, unita_aziendale.bdn_id AS unita_aziendale_bdn_id, unita_aziendale.codice_struttura AS unita_aziendale_codice_struttura, unita_aziendale.id_azienda AS unita_aziendale_id_azienda, anon_b406.peso AS anon_b406_peso, anon_b406.tempo AS anon_b406_tempo, anon_b406.id_unita_aziendale AS anon_b406_id_unita_aziendale, anon_b406.data_aggiornamento AS anon_b406_data_aggiornamento, unita_aziendale.bdn_specie AS unita_aziendale_bdn_specie, unita_aziendale.id_precedente AS unita_aziendale_id_precedente, unita_aziendale.bdn_flag_carne_latte AS unita_aziendale_bdn_flag_carne_latte, unita_aziendale.data_fine AS unita_aziendale_data_fine, unita_aziendale.stato_record AS unita_aziendale_stato_record, anon_b3be.cod_nazionalita AS anon_b3be_cod_nazionalita, anon_b3be.id AS anon_b3be_id, anon_b3be.id_comune AS anon_b3be_id_comune, anon_b3be.cod_professione AS anon_b3be_cod_professione, anon_b3be.dato_fiscale AS anon_b3be_dato_fiscale, anon_b3be.localita AS anon_b3be_localita, anon_b3be.telefono AS anon_b3be_telefono, anon_b3be.email AS anon_b3be_email, anon_b3be.nome AS anon_b3be_nome, anon_b3be.tipo AS anon_b3be_tipo, anon_b3be.cod_titolo_studio AS anon_b3be_cod_titolo_studio, anon_b3be.indirizzo AS anon_b3be_indirizzo, anon_b3be.id_precedente AS anon_b3be_id_precedente, anon_b3be.cod_nazione_nascita AS anon_b3be_cod_nazione_nascita, anon_b3be.id_comune_nascita AS anon_b3be_id_comune_nascita, anon_b3be.stato_record AS anon_b3be_stato_record, anon_b3be.id_operatore AS anon_b3be_id_operatore, anon_b3be.cap AS anon_b3be_cap, anon_b3be.ts_ultima_modifica AS anon_b3be_ts_ultima_modifica, anon_b3be.data_nascita AS anon_b3be_data_nascita \nFROM unita_aziendale LEFT OUTER JOIN scheda_totali AS anon_b406 ON unita_aziendale.id = anon_b406.id_unita_aziendale LEFT OUTER JOIN anagrafica AS anon_b3be ON anon_b3be.id = unita_aziendale.id_anagrafica ORDER BY anagrafica.nome, anon_b406.id_unita_aziendale, anon_b3be.id' {} Anagrafica is a table implicated in the mapper UnitaAziendale, so i expect a correct ordering, but seems SA don't consider to have aliased during the select anagrafica as anon_b3be. When compiler add order_by condition he use ORDER BY anagrafica.nome as indicated in the function. But i'm confused now... SA tell me that he have renamed this table but create a wrong qry...why this appens? Thank's Glauco -- ++ Glauco Uri - Programmatore glauco(at)allevatori.com Sfera Carta Software(R) [EMAIL PROTECTED] Via Bazzanese,69 Casalecchio di Reno(BO) - Tel. 051591054 ++ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: SQLAlchemy 0.4beta6 released !!
On Sep 27, 2007, at 12:17 AM, Jose Galvez wrote: Dear Micheal, Does this mean that with web apps since the session is now weak referencing that we will no longer have to call Session.remove() to clear out Sessions? Specifically I'm referencing what Mike Orr wrote in the pylonscookbook. Jose you might be able to get away with that, but its still a good idea to call Session.remove() at the end of a request since its not a guarantee that things wont be lying around from the previous request. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: aliased tables
On 9/27/07, Glauco [EMAIL PROTECTED] wrote: Glauco, can you send a small test script reproducing the error ? I'll gladly take a look at that... Cheers, Roger Yes... this is the example session.query( UnitaAziendale ).order_by(Anagrafica.c.nome) SNIP Thanks Glauco... But you forgot your Tables and mappers definition... ;) Ah, and which database are you using ? Are you using SA 0.3 or SA 0.4 ? Roger --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: SQLAlchemy 0.4beta6 released !!
Thanks for the info and thanks for some great software Jose On Sep 27, 8:03 am, Michael Bayer [EMAIL PROTECTED] wrote: On Sep 27, 2007, at 12:17 AM, Jose Galvez wrote: Dear Micheal, Does this mean that with web apps since the session is now weak referencing that we will no longer have to call Session.remove() to clear out Sessions? Specifically I'm referencing what Mike Orr wrote in the pylonscookbook. Jose you might be able to get away with that, but its still a good idea to call Session.remove() at the end of a request since its not a guarantee that things wont be lying around from the previous request. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] OID usage
I apologize in advance for the size of this post, but I want to provide as much info as possible. I work for a large company and I am trying to use SqlAlchemy to implement a cleaner interface to one of our databases. The database is Sql Server 2005, the app runs on RHEL 3 under Python 2.5. I am using SqlAlchemy 0.4.0beta5. Our corporate DBAs use OIDs, Binary(8) fields as key fields on our tables. I am pulling this information for use by various applications and need to be able to query the database based on these keys. I have tried a couple different means of pulling the keys and re- querying, and have yet to have a query succeed. Here is the custom class I created to try and have the value display in an intermediate format that is legible within the app and then converted back when it comes time to query based on the key. dbutils.py: --- class OID(types.TypeDecorator): Uninterprets the OID key value into a readable string impl = types.Binary def convert_bind_param(self, value, engine): bytes = [] for x in range(0, len(value), 2): bytes.append( chr( int (value[x:x+2], 16 ) ) ) return %s % ''.join( bytes ) def convert_result_value(self, value, engine): return %s % ''.join([%02X % ord(x) for x in value]) This is the mapper file for the table in question. Notice the commented out line for using my custom class and the line where I tried to use the built-in Binary type. specsections.py # Define spec_configuration_options table spec_sections_table = Table('spec_sections', metadata, #Column( 'section_OID', dbutils.OID(), primary_key=True ), Column( 'section_OID', types.Binary(8), primary_key=True ), Column( 'product_name', types.String(30), nullable=False ), Column( 'density_value', types.String(8), nullable=False ), Column( 'datasheet_type', types.String(50), nullable=False ), Column( 'temp_range_min', types.String(10), nullable=False ), Column( 'temp_range_max', types.String(10), nullable=False ), Column( 'section_name', types.String(100), nullable=False ), Column( 'design_id', types.String(50), nullable=True ), Column( 'interface_type', types.String(50), nullable=True) ) class SpecSections(object): def __init__(self, section_OID, product_name, density_value, datasheet_type, temp_range_min, temp_range_max, section_name, design_id, interface_type): self.section_OID = section_OID self.product_name = product_name self.density_value = density_value self.datasheet_type = datasheet_type self.temp_range_min = temp_range_min self.temp_range_max = temp_range_max self.section_name = section_name self.design_id = design_id self.interface_type = interface_type def __repr__(self): return ::.join([self.section_OID, self.product_name, self.density_value, self.datasheet_type, self.temp_range_min, self.temp_range_max, self.section_name, self.design_id, self.interface_type] ) specsections_mapper = Session.mapper(SpecSections, spec_sections_table) Here is an example of a properly interpreted row using the dbutils.OID class: 08C82B7C6A844743::SDRAM::64Mb::Marketing::0C::70C::DC Electrical Characteristics Here is the binding statement being generated by SqlAlchemy: 2007-09-27 13:32:12,444 INFO sqlalchemy.engine.base.Engine.0x..cL {'spec_section_symbols_section_OID': '\x08\xc8+|j\x84GC'} I am not receiving any type of error, just an empty result set. I have verified that the OID is being interpreted correctly by running an interactive sql statement on the interpreted value shown. I know in Perl I have to format the query without quotes or I don't get any results. Something like this: select * from table where section_OID=0x08C82B7C6A844743 I'm wondering if SqlAlchemy is quoting the parameter when it is bound or if anyone has any other suggestions as to why I am not getting any results. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] polymorphic question
i know in 0.4 one can request a polymorphic request to be automaticaly split into multiple per-subtype requests. i've no idea how this compares +/- to the huge union/outerjoin that gives all in one long shot. my question is.. can this mechanism/approach be used somehow for (semi) automatic vertical loading, i.e. instead of loading all items in all rows, load only some items normaly while (pre)loading some specific columns in whole in one separate shot? say there is a table X having a,b,c..p,q. So i do a plain row query over X, getting a,b,c,d per row, and request the p and q columns (pre)loaded whole (or partial as per some limit). i imagine this to be useful to avoid zillions of eagerloads/joins etc (when the columns in question are links to somewhere). but i might be wrong... - i've no idea how the eagerloading scales. Any arguments pro/con? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: 0.4 and server-side cursors
looks like it won't work using psycopg2's named cursor implementation, at least not without some patching. it seems like psycopg should fill in cursor.description after it issues the DECLARE, but it doesn't. you can do it using one normal (non-named) cursor in SA using the method above, but it would probably require some significant work, since you'd have to transform SELECT statements into FETCH statements. anyway, thanks for the fix! On Sep 26, 8:01 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Sep 26, 2007, at 5:31 PM, Dan Watson wrote: cursor.description isn't available after the DECLARE (analogous to conn.cursor(x)), but is available after a FETCH (analogous to a cur.fetchXXX()). If you want to get rid of the buffering resultproxy, you can do a FETCH ABSOLUTE 0 FROM cursor_name - that will make cursor.description available, and leave the SS cursor positioned before the first row. hm does that require a second cursor ? its giving me cant execute twice on a named cursor. if so, the current approach we have is probably more efficient... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: OID usage
just some ideas. Here is an example of a properly interpreted row using the dbutils.OID class: 08C82B7C6A844743::SDRAM::64Mb::Marketing::0C::70C::DC Electrical Characteristics Here is the binding statement being generated by SqlAlchemy: 2007-09-27 13:32:12,444 INFO sqlalchemy.engine.base.Engine.0x..cL {'spec_section_symbols_section_OID': '\x08\xc8+|j\x84GC'} I know in Perl I have to format the query without quotes or I don't get any results. Something like this: select * from table where section_OID=0x08C82B7C6A844743 the dict shows that your value is sent/assumed a raw byte-string, while what u're suggesting in the perl example is that the server expects a sort of hexadecimal longint representation. Are these equivalent? maybe u need to convert from one to another? I am not receiving any type of error, just an empty result set. I have verified that the OID is being interpreted correctly by running an interactive sql statement on the interpreted value shown. I'm wondering if SqlAlchemy is quoting the parameter when it is bound or if anyone has any other suggestions as to why I am not getting any results. insert one row via sqlalchey with OID=aabbccddeeff and see what u get. may give u idea of what conversion happens on the way. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: OID usage
On Sep 27, 2007, at 4:11 PM, Eric N wrote: I'm wondering if SqlAlchemy is quoting the parameter when it is bound or if anyone has any other suggestions as to why I am not getting any results. we're not quoting anything when its bound...what gets returned from convert_bind_param is what gets sent as a bind param to cursor.execute (). your custom type class seems fine. what you should do here first is make a short program using DBAPI only (which DBAPI are you using ? the three available for MS-SQL vary widely in their functionality), and try to get the query to work using a straight cursor.execute(). there could be issues with comparisons to binary fields or with the DBAPI's ability to bind a binary field; a call to setinputsizes() may even be needed. once its determined exactly what your DBAPI needs (or if its possible at all). any additional data massaging needed on the SQLAlchemy side can then be addressed. as a last resort you can inject direct text into a SQL statement using a string...with ORM it would look like query.filter (section_OID=0x08C82B7C6A844743) . --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: polymorphic question
On Sep 27, 2007, at 3:53 PM, [EMAIL PROTECTED] wrote: i know in 0.4 one can request a polymorphic request to be automaticaly split into multiple per-subtype requests. i've no idea how this compares +/- to the huge union/outerjoin that gives all in one long shot. my question is.. can this mechanism/approach be used somehow for (semi) automatic vertical loading, i.e. instead of loading all items in all rows, load only some items normaly while (pre)loading some specific columns in whole in one separate shot? say there is a table X having a,b,c..p,q. So i do a plain row query over X, getting a,b,c,d per row, and request the p and q columns (pre)loaded whole (or partial as per some limit). i imagine this to be useful to avoid zillions of eagerloads/joins etc (when the columns in question are links to somewhere). but i might be wrong... - i've no idea how the eagerloading scales. Any arguments pro/con? if youre talking about just one table X, deferred columns will hold off the loading of those columns until they are accessed. as far as the joined tables, polymorphic_fetch=deferred will leave those to be loaded when those attributes are first accessed. that's as well as I understand your question so far --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Beta6 - sqlsoup - SADeprecationWarning
Hello, I get the following warning message, after the upgrade to 0.4 beta6. /usr/lib/python2.4/site-packages/SQLAlchemy-0.4.0beta6-py2.4.egg/ sqlalchemy/ext/sqlsoup.py:356: SADeprecationWarning: SessionContext is deprecated. Use scoped_session(). Is there any quickfix ? Thank you --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---