[sqlalchemy] Re: __init__ method

2018-04-27 Thread Jose Miguel Ibáñez
recommended ? El jueves, 26 de abril de 2018, 18:48:53 (UTC+2), Jose Miguel Ibáñez escribió: > > Hi all ! > > when defining a class (derived from Base), when is recommended to define > the __init__() method ? I know this consideration https://goo.gl/2umBJv, > but I can't see

[sqlalchemy] __init__ method

2018-04-26 Thread Jose Miguel Ibáñez
Hi all ! when defining a class (derived from Base), when is recommended to define the __init__() method ? I know this consideration https://goo.gl/2umBJv, but I can't see the diference when creating objects for database population. It seems __init_() is never required. Thanks ! José M. --

Re: [sqlalchemy] python customer function

2015-05-11 Thread Jose Soares
thanks for point me to this docs, Jonathan, I'm going to take a look at it. j On 08/05/2015 23:30, Jonathan Vanasco wrote: Would you be able to use a TypeDecorator? http://docs.sqlalchemy.org/en/latest/core/custom_types.html#sqlalchemy.types.TypeDecorator That will allow you to define a

Re: [sqlalchemy] python customer function

2015-05-08 Thread Jose Soares
Hi Mike, thanks to reply my question. In my case the extract function is unuseful because it needs a datetime to extract parts of it but I don't have a datetime but a codified date. I need to manage a string which is a personal code with info about name, birthday, birth place and gender.

[sqlalchemy] is True vs ==True

2015-03-30 Thread Jose Soares
Hi all, While I changed some obsolete syntax as defined in (https://www.python.org/dev/peps/pep-0008/) like (is True instead of ==True) also False and None. I realized that sqlalchemy do not support them What can I do to avoid this behavior?

Re: [sqlalchemy] is True vs ==True

2015-03-30 Thread Jose Soares
Hmm! in this case we must distinguish between the python syntax and the sqlalchemy syntax.:-( j On 30/03/2015 12:37, Simon King wrote: On Mon, Mar 30, 2015 at 10:59 AM, Jose Soares jose.soa...@sferacarta.com wrote: Hi all, While I changed some obsolete syntax as defined in (https

Re: [sqlalchemy] is True vs ==True

2015-03-30 Thread Jose Soares
(Rischio.c.peso_gruppo == sa.**sql.true()**)* :) On 03/30/2015 10:52 AM, Jose Soares wrote: Hmm! in this case we must distinguish between the python syntax and the sqlalchemy syntax.:-( j On 30/03/2015 12:37, Simon King wrote: On Mon, Mar 30, 2015 at 10:59 AM, Jose Soares jose.soa

Re: [sqlalchemy] DefaultClause

2015-01-12 Thread Jose Soares
scritto: use server_default with text() as documented at http://docs.sqlalchemy.org/en/rel_0_9/core/defaults.html#server-side-defaults. jo jose@sferacarta.com wrote: Hi all, I have a problem with DefautClause. I need to assign a default to a numeric column. tbl['rischio_attivita

Re: [sqlalchemy] session query and column names

2015-01-12 Thread Jose Soares
Why don't you pass the params to session.query as a dictionary into filter_by as in: In [1]: by_where_clause=dict(specie_codice='42', specie_descrizione='Nutrie') In [2]: print session.query(Specie).filter_by( **by_where_clause ).count() 2015-01-12 12:37:40,518 INFO

[sqlalchemy] UNION howto

2014-10-01 Thread Jose Soares
Hi all, Could someone help me to define in sqlalchemy the following query: sql=SELECT count(*) FROM (SELECT cod_sticker AS bruciato FROM scadenziario UNION SELECT cod_sticker AS bruciato FROM sopralluogo UNION SELECT sticker_checklist AS bruciato FROM sopralluogo

[sqlalchemy] VARCHAR(None CHAR)

2013-11-22 Thread Jose Soares
|| %(sezionale_1)s || CAST(fattura_master.anno AS VARCHAR) || %(param_1)s || CAST(fattura_master.numero AS VARCHAR) AS pk FROM fattura_master In [3]: qry.count() /home/jose/buildout/eggs/SQLAlchemy-0.6.8-py2.6.egg/sqlalchemy/engine/default.py:518: SAWarning: Unicode type received non-unicode bind param

Re: [sqlalchemy] VARCHAR(None CHAR)

2013-11-22 Thread Jose Soares
Ok. It works, thanks, Michael j On 11/22/2013 04:22 PM, Michael Bayer wrote: On Nov 22, 2013, at 4:50 AM, Jose Soares jose.soa...@sferacarta.com wrote: Hi all, I have a query generated by sqlalchemy like this: SELECT fattura_master.tipo_documento AS fattura_master_tipo_documento

Re: [sqlalchemy] distinct on

2013-05-24 Thread Jose Soares
Thanks for reply, Mariano. j On 05/23/2013 12:37 PM, Mariano Mara wrote: On 05/23/2013 04:42 AM, jo wrote: |Hi all, I wondered if it is possible to execute a partial distinct in sqlalchemy. The following query works in oracle and postgresql: select distinct col1, first_value(col2) over

[sqlalchemy] joinedload + limit

2013-03-21 Thread Jose Neto
Given the following statement: p = db.query(Profile).options(joinedload('*')).filter_by(id=p.id).limit(1).one() I will get a subquery + a join, instead of a pure join: SELECT [...] FROM (SELECT profile.id AS profile_id, ...FROM profile WHERE profile.id = %(id_1)s LIMIT %(param_1)s) AS

[sqlalchemy] query.filter AND ( ... OR ... OR ) how to?

2013-01-23 Thread Jose Soares
Hi all, I'm trying to compile a query to avoid Oracle limit of 1000 in IN(): def chunks(l, n): Yield successive n-sized chunks from l. for i in xrange(0, len(l), n): yield l[i:i+n] qry=session.query(Azienda).fiter(Azienda.c.cap=='') val=[1,3,3,4,3,23,2,4,5,6,7,8,9,90,34,2]

Re: [sqlalchemy] query.filter AND ( ... OR ... OR ) how to?

2013-01-23 Thread Jose Soares
It works, thanks Simon. j On 01/23/2013 12:53 PM, Simon King wrote: On Wed, Jan 23, 2013 at 11:30 AM, Jose Soares jose.soa...@sferacarta.com wrote: Hi all, I'm trying to compile a query to avoid Oracle limit of 1000 in IN(): def chunks(l, n): Yield successive n-sized chunks from l

Re: [sqlalchemy] NotSupportedError

2012-04-19 Thread jose soares
Yes, now it works, thanks a lot Michael. :-) j Michael Bayer wrote: func.cast() is not correct. Use the cast() function which handles this special syntax: from sqlalchemy import cast, Integer from sqlalchemy.sql import column from sqlalchemy.dialects import oracle print cast(column('x'),

Re: [sqlalchemy] sqlalchemy.exc.DatabaseError: (DatabaseError) ORA-12505: TNS:listener does not currently know of SID given in connect descriptor

2011-12-19 Thread jose soares
Michael Bayer wrote: On Dec 17, 2011, at 1:52 AM, jo wrote: create_engine(oracle://user:password@SHELL) could you tell me how it becomes in sqlalchemy.dburi on tg prod.cfg ? sqlalchemy.dburi=oracle://username:password@host:port/service_name I tried in this way:

Re: [sqlalchemy] sqlalchemy.exc.DatabaseError: (DatabaseError) ORA-12505: TNS:listener does not currently know of SID given in connect descriptor

2011-12-19 Thread jose soares
Michael Bayer wrote: On Dec 19, 2011, at 3:28 AM, jose soares wrote: I tried as you said Michael and this is the error message: sqlalchemy.exc.DatabaseError: (DatabaseError) ORA-12154: TNS:could not resolve the connect identifier specified I tried like so: sqlalchemy.dburi=oracle

Re: [sqlalchemy] sqlalchemy.exc.DatabaseError: (DatabaseError) ORA-12505: TNS:listener does not currently know of SID given in connect descriptor

2011-12-19 Thread jose soares
Michael Bayer wrote: On Dec 19, 2011, at 10:17 AM, jose soares wrote: Michael Bayer wrote: On Dec 19, 2011, at 3:28 AM, jose soares wrote: I tried as you said Michael and this is the error message: sqlalchemy.exc.DatabaseError: (DatabaseError) ORA-12154: TNS:could

Re: [sqlalchemy] sqlalchemy.exc.DatabaseError: (DatabaseError) ORA-12505: TNS:listener does not currently know of SID given in connect descriptor

2011-12-19 Thread jose soares
Michael Bayer wrote: On Dec 19, 2011, at 10:43 AM, jose soares wrote: this is my tnsnames.ora: # tnsnames.ora Network Configuration File: /usr/share/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora # Generated by Oracle configuration tools. LISTENER_SICER = (ADDRESS

Re: [sqlalchemy] sqlalchemy.exc.DatabaseError: (DatabaseError) ORA-12505: TNS:listener does not currently know of SID given in connect descriptor

2011-12-14 Thread jose soares
): #this doesn't work import cx_Oracle dsn = cx_Oracle.makedsn(parms['host'],parms['port'],parms['sid']) return cx_Oracle.connect(parms['user'], parms['password'], dsn) jose soares wrote: Hi Michael, I tried your script. the cx_Oracle.connect, works but the create_engine doesn't

Re: [sqlalchemy] sqlalchemy.exc.DatabaseError: (DatabaseError) ORA-12505: TNS:listener does not currently know of SID given in connect descriptor

2011-12-14 Thread jose soares
) ) ) maybe there's a discrepancy between the hostnames in use in the file vs. your URL. On Dec 14, 2011, at 4:50 AM, jose soares wrote: I also tried two different connection mode. The first one works but the second one using makedsn doesn't. def init_db_conn(parms): #this work import

[sqlalchemy] sqlalchemy.exc.DatabaseError: (DatabaseError) ORA-12505: TNS:listener does not currently know of SID given in connect descriptor

2011-12-13 Thread jose soares
Hi all, I'm trying to connect to an oracle db using sqlalchemy with turbogears1 and I get this error: sqlalchemy.exc.DatabaseError: (DatabaseError) ORA-12505: TNS:listener does not currently know of SID given in connect descriptor I tried making the connection using cs_Oracle and it

[sqlalchemy] MultipleResultsFound

2011-03-30 Thread jose soares
Hi all, I got, for the first time the following error: ../lib/python2.6/site-packages/SQLAlchemy-0.6.0-py2.6.egg/sqlalchemy/orm/query.py, line 1417, in one Multiple rows were found for one()) MultipleResultsFound: Multiple rows were found for one() Does anyone know what that means? j

Re: [sqlalchemy] MultipleResultsFound

2011-03-30 Thread jose soares
Mike Conley wrote: You issued a query with a .one() qualifier and there is more than one row in the database satisfying the condition. Example: 2 names in a table firstname=pete, lastname=smith firstname=john, lastname=smith query for rows lastname=smith with .one() will fail because there

[sqlalchemy] joinedload alias

2010-05-21 Thread jose soares
Hi all, I'm trying to use joinedload('specie') in a query but it makes an unexpected alias of table name to 'specie_1' and it conflict with passed orderby column specie.descrizione, as in: ProgrammingError: ('(ProgrammingError) invalid reference to FROM-clause entry for table specie\nLINE

[sqlalchemy] ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1

2010-05-19 Thread jose soares
Hi all, Someone knows what this error mean? ... File /home/ve/sfera/release/sicer/BASE/model/anagraficaAlta/unita_aziendale.py, line 154, in aggiorna_capi_bovini x.flush() File /home/ve/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg/sqlalchemy/ext/assignmapper.py, line 20, in

[sqlalchemy] CheckConstraint compatibility

2010-05-19 Thread jose soares
Hi all, I have to create a constraint like this: CheckConstraint('data_start = CURRENT_DATE'), it works for PostgreSQL but it doesn't work for Oracle10. Is there some workaround to make it compatible with pg and oracle? j -- You received this message because you are subscribed to the

Re: [sqlalchemy] about commit()

2010-04-23 Thread jose soares
Mariano Mara wrote: Excerpts from jo's message of Fri Apr 23 03:16:21 -0300 2010: Hi all, I need to insert a new row and get back the last inserted id, I have some difficulty using the flush(), then I'm trying with commit() but I can't understand how commit() works in 0.6. In the following

Re: [sqlalchemy] about commit()

2010-04-23 Thread jose soares
jo wrote: Hi all, I need to insert a new row and get back the last inserted id, I have some difficulty using the flush(), then I'm trying with commit() but I can't understand how commit() works in 0.6. In the following script I try to update a row and it works properly but when I try to

Re: [sqlalchemy] about commit()

2010-04-23 Thread jose soares
Lance Edgar wrote: On 4/23/2010 9:19 AM, jose soares wrote: jo wrote: Hi all, I need to insert a new row and get back the last inserted id, I have some difficulty using the flush(), then I'm trying with commit() but I can't understand how commit() works in 0.6. In the following script I try

Re: [sqlalchemy] about commit()

2010-04-23 Thread jose soares
Yes Lance, now it works, thank you v.m. :-) j Lance Edgar wrote: On 4/23/2010 9:19 AM, jose soares wrote: jo wrote: Hi all, I need to insert a new row and get back the last inserted id, I have some difficulty using the flush(), then I'm trying with commit() but I can't understand how commit

Re: [sqlalchemy] cls._state / cls._state.get('original') class 'sqlalchemy.orm.attributes.CommittedState'

2010-04-16 Thread jose soares
jo wrote: Hi all, I cannot find anymore the attribute _state : if (not cls._state or not cls._state.get('original') or (cls._state['original'].data.get(k) != data.get(k: Could someone please help me? thank you j To explain better my problem, in version 0.3 my models have the

Re: [sqlalchemy] cls._state / cls._state.get('original') class 'sqlalchemy.orm.attributes.CommittedState'

2010-04-16 Thread jose soares
King Simon-NFHD78 wrote: -Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of jose soares Sent: 16 April 2010 11:03 To: sqlalchemy@googlegroups.com Subject: Re: [sqlalchemy] cls._state / cls._state.get('original') class

Re: [sqlalchemy] column_prefix

2010-04-16 Thread jose soares
I am sorry Michael, Maybe the problem is not in the column_prefix, The thing that I don't understand in this query is why sa tries to change the primary key of this row. I changed in my form only the value of id_operator, thus I expected a query like: UPDATE anagrafica SET id_operatore=1695

Re: [sqlalchemy] cls._state / cls._state.get('original') class 'sqlalchemy.orm.attributes.CommittedState'

2010-04-16 Thread jose soares
= sa.create_engine('sqlite://') Base.metadata.create_all(bind=engine) Session = saorm.sessionmaker(bind=engine) sess = Session() u = User(name='jose') sess.add(u) display_history('Before commit', u, 'name') sess.commit() u = sess.query(User).get(1) display_history('After load', u, 'name') u.name

[sqlalchemy] TypeError: synonym() got an unexpected keyword argument

2010-04-14 Thread jose soares
Hi all, seems synonym in version 0.6 don't have proxy parameter. 'user_name' : synonym('logname', proxy=True), TypeError: synonym() got an unexpected keyword argument 'proxy' j -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this

Re: [sqlalchemy] Re: TypeError: synonym() got an unexpected keyword argument

2010-04-14 Thread jose soares
Yes I see, now, thank you, Williams. j GHZ wrote: Hi, http://www.sqlalchemy.org/changelog/CHANGES_0_6beta3 * 'proxy' argument on synonym() is removed. This flag did nothing throughout 0.5, as the proxy generation behavior is now automatic. On 14 apr, 13:16, jose

Re: [sqlalchemy] SQLAlchemy.func.max()

2010-04-08 Thread jose soares
Michael Bayer wrote: jo wrote: I was using heavily the column_prefix and my code is full of it, as in: mapper(Anagrafica, tbl['anagrafica'], column_prefix = 'anagrafica_', extension=History(), properties = { 'comune' : relation( Comune,

[sqlalchemy] TypeError: unsupported operand type(s) for +: 'Decimal' and 'float'

2010-04-06 Thread jose soares
Hi all, I'm using Oracle and PostgreSQL with SQLAlchemy and I have some troubles to make the code compatible with both of them. Numeric sa type returns a different type with oracle and pg. For example, in the following table I'm using the Column 'importo' with type Numeric as:

Re: [sqlalchemy] TypeError: unsupported operand type(s) for +: 'Decimal' and 'float'

2010-04-06 Thread jose soares
Michael Bayer wrote: jose soares wrote: Hi all, I'm using Oracle and PostgreSQL with SQLAlchemy and I have some troubles to make the code compatible with both of them. Numeric sa type returns a different type with oracle and pg. For example, in the following table I'm using the Column

[sqlalchemy] UniqueConstraint case sensitive

2010-03-26 Thread jose soares
Hi all, I would like to create an UniqueConstraint like this one: CREATE UNIQUE INDEX uniqinx ON prod(lower(name)) Could you help me to translate it to SQLAlchemy using UniqueConstraint ? Thank you. j -- You received this message because you are subscribed to the Google Groups

[sqlalchemy] incoherent behavior between oracle and postgres on engine.rowcount

2009-01-24 Thread Jose Soares
Hi all, I wonder why there's such difference between oracle and pg: oracle: (Pdb) engine.connect().execute(sql).fetchone() select * from ruolo_permesso where cod_ruolo = 'SYSADMIN' and cod_permesso='TIPO_FIGURA' and inserimento='1' None (1273, 'SYSADMIN', 'TIPO_FIGURA', 1, 1, 1, 1) (Pdb)

[sqlalchemy] TypeError: can't compare offset-naive and offset-aware datetimes

2008-12-10 Thread jose
Hi, What this message means? self.save_objects(trans, task) File /usr/lib/python2.4/site-packages/sqlalchemy/orm/unitofwork.py, line 1023, in save_objects task.mapper.save_obj(task.polymorphic_tosave_objects, trans) File /usr/lib/python2.4/site-packages/sqlalchemy/orm/mapper.py,

[sqlalchemy] Re: case_sensitive

2008-12-09 Thread jose
I tried it, as you suggested me, Michael... Index('valuta_desc_uniq', func.lower(valuta.c.descrizione), unique=True) File /usr/lib/python2.4/site-packages/sqlalchemy/schema.py, line 1045, in __init__ self._init_items(*columns) File

[sqlalchemy] circular reference

2008-12-06 Thread jose
Hi all, I have two tables in my schema with circular references and I don't know hot to create them. tbl['anagrafica']=Table('anagrafica',database.metadata, Column('id', Integer, Sequence('anagrafica_id_seq'), primary_key=True, nullable=False), Column('nome', Unicode(200),

[sqlalchemy] create index with a condition

2008-12-06 Thread jose
Hi all, I would like to create an index with a condition, like this: CREATE UNIQUE INDEX univocita_codice_aziendale on azienda (lower(codice_aziendale), stato_record) WHERE stato_record = 'A' Is there a way to do that, using the Index() command? j

[sqlalchemy] Re: Column('last_updated', onupdate=func.current_timestamp())

2008-12-06 Thread jose
Yes, Michael, I see how it works now. Thank you j Michael Bayer wrote: that is the correct syntax. It will take effect any time an update() construct is used or when the ORM updates a row. Because onupdate is not a DDL-side construct, it will not take effect if you use a plain text

[sqlalchemy] Re: circular reference

2008-12-06 Thread jose
) Michael Bayer wrote: specify use_alter=True to one or both ForeignKey constructs. On Dec 6, 2008, at 12:37 PM, jose wrote: Hi all, I have two tables in my schema with circular references and I don't know hot to create them. tbl['anagrafica']=Table('anagrafica',database.metadata

[sqlalchemy] Re: create index with a condition

2008-12-06 Thread jose
://www.sqlalchemy.org/docs/05/reference/sqlalchemy/schema.html?highlight=ddl#sqlalchemy.schema.DDL On Dec 6, 2008, at 1:15 PM, jose wrote: Hi all, I would like to create an index with a condition, like this: CREATE UNIQUE INDEX univocita_codice_aziendale on azienda (lower(codice_aziendale), stato_record

[sqlalchemy] Re: circular reference

2008-12-06 Thread jose
I gave it a name but now... raise FlushError(Circular dependency detected + repr(edges) + repr(queue)) sqlalchemy.exceptions.FlushError: Circular dependency detected sqlalchemy.topological._EdgeCollection object at 0xb73f356c[] jose wrote: the use_alter=True raises this error

[sqlalchemy] Re: Elixir 0.6.1 released!

2008-08-19 Thread Jose Galvez
relationships to be difficult at times Jose Jorge Vargas wrote: On Mon, Aug 18, 2008 at 11:37 PM, Jose Galvez [EMAIL PROTECTED] wrote: I'm not trying to be an ass, but what are the advantages to using Elixer well you did sound like one :) the first thing is that declarative is very new

[sqlalchemy] declarative

2008-08-19 Thread Jose Galvez
looks like a mich simplier and more feature complete then declarative, but It does not look like Elixir works with a legacy databse (but I'm still looking into that) so I was wondering about declarative's long term stability. Thanks Jose

[sqlalchemy] Re: declarative

2008-08-19 Thread Jose Galvez
I take it back about Elixir and legacy databases, it seems to work with them just as easy as sqlalchemy does. I'll have to look much closer at Elixir Jose Jose Galvez wrote: What is the proposed stability of declarative functions which I guess are pretty new. From what I've read so far I

[sqlalchemy] Re: Elixir 0.6.1 released!

2008-08-18 Thread Jose Galvez
' % (self.fname, self.lname) print 'first get everyone in the database' people = People.query() for p in people: print p Jose Gaetan de Menten wrote: I am very pleased to announce that version 0.6.1 of Elixir (http://elixir.ematia.de) is now available. As always, feedback is very welcome

[sqlalchemy] Re: SQLAlchemy 0.4beta6 released !!

2007-09-27 Thread jose
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

[sqlalchemy] Re: SQLAlchemy 0.4beta6 released !!

2007-09-26 Thread Jose Galvez
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 Michael Bayer wrote: This should hopefully

[sqlalchemy] Re: Import problem

2007-09-20 Thread Jose Galvez
what error do you get is you enter import sqlalchemy Jose Goutham Lakshminarayan wrote: This might trivial to most of u but Iam having problems importing sqlalchemy on windows. The installation went without a problem but when i went to site packages directory there was a SQLAlchemy-0.3.10

[sqlalchemy] Re: SAContext 0.3.0

2007-07-11 Thread Jose Galvez
(sqlalchemy.key.uri). So what I would advocate is eliminating the special default and just make users specify the correct key, I think that would be much less ambiguous then None Jose On 7/11/07, Mike Orr [EMAIL PROTECTED] wrote: On 7/11/07, Jose Galvez [EMAIL PROTECTED] wrote: Dear Mike, I've

[sqlalchemy] Re: SAContext 0.3.0

2007-07-11 Thread Jose Galvez
I've just reread the sacontext doc string and realize that what I've said really does not make any sense. To go back a step I would advocate using default rather then None Jose On 7/11/07, Jose Galvez [EMAIL PROTECTED] wrote: Well I would prefer not using None and rather making the user pass

[sqlalchemy] Re: query date field

2007-07-07 Thread Jose Galvez
Thanks, everyone for the pointers. Since func is not database agnostic, I think I'll make my own functions in my database module that simply use func so if I ever do switch form mysql to something else at least I'll know where to find all the stuff that needs changing Jose jose wrote: I've got

[sqlalchemy] Re: whats going to break in 0.4

2007-07-05 Thread Jose Galvez
Got it thanks jose Michael Bayer wrote: On Jul 4, 7:30 pm, Jose Galvez [EMAIL PROTECTED] wrote: Thanks Michael, I went back and reread the Proposal thread and I finally get what scalar() does and how it is different form one(). but how would first() differ from scalar() and how would

[sqlalchemy] detached instance or is already persistent in a different Sess

2007-04-19 Thread jose
hi group, I have the following error that I don't know how to solve... * -- *self.record = Comune.get(pk) *... *self.record.get_from_dict(data=data,update=True) if self.record._state['modified']: self.record.save()

[sqlalchemy] Re: lower / upper case

2007-04-18 Thread Jose Soares
Disrupt07 ha scritto: I have a users table and I want to query the usernames column. I want my query to ignore the upper/lower casing. So the following searches should all match John: john, jOhn, johN, JOhn, and so on. My query at the moment is a follows: names =

[sqlalchemy] select() got multiple values for keyword argument 'from_obj'

2007-04-02 Thread Jose Soares
Hi all, I'm trying to create the following query using SA: SELECT DISTINCT operatore.id, anagrafica.nome, acl.cod_ruolo FROM operatore JOIN anagrafica ON operatore.id_anagrafica = anagrafica.id LEFT OUTER JOIN acl ON acl.id_operatore = operatore.id LEFT OUTER JOIN ruolo_permesso ON

[sqlalchemy] Re: select() got multiple values for keyword argument 'from_obj'

2007-04-02 Thread Jose Soares
King Simon-NFHD78 ha scritto: Shouldn't acl.cod_ruolo be inside the [] - part of the first parameter to 'select'? The parameters to select are 'columns=None, whereclause=None, from_obj=[], **kwargs', so your 'and_' part is going in as the from_obj parameter, and then you are supplying

[sqlalchemy] Re: SELECT 'a fixed string', ...

2007-03-20 Thread jose
Bertrand Croq wrote: hi, I am currently using sqlalchemy to build SQL queries and it's a fantastic tool! By now, I am looking for a way to build: SELECT 'a_fixed_string', atable.col1, atable.col2 FROM atable using the syntax: select([XXX, atable.c.col1, atable.c.col2]) but I don't know

[sqlalchemy] Re: use_labels =30 vs MAX_LABEL_LENGTH

2007-03-17 Thread jose
, etc. Indices are similarly unconstrained). On Mar 16, 2007, at 4:05 PM, Jose Soares wrote: Hi Michael, I see that sql.py uses a limit of 30 characters to create the column label when use_labels is set to True. If name is greater than 30 char long, the label is trunked at position 24

[sqlalchemy] use_labels =30 vs MAX_LABEL_LENGTH

2007-03-16 Thread Jose Soares
Hi Michael, I see that sql.py uses a limit of 30 characters to create the column label when use_labels is set to True. If name is greater than 30 char long, the label is trunked at position 24 and is appended a random integer to it. Since the name created in this way is less useful, I would

[sqlalchemy] Re: error compile

2007-03-16 Thread Jose Soares
Sébastien LELONG ha scritto: Seems that SA compiles in a wrong way my query... Can't what's wrong is happening... subvet appers to be a sub-select, so probably SA made some optimizations. You should print the whole query (print sql) and not the sub-query (as in your code: print

[sqlalchemy] Re: error compile

2007-03-16 Thread Jose Soares
Sébastien LELONG ha scritto: As you can see the from_obj of subselect is wrong, the FROM should be: FROM azienda_veterinario, unita_aziendale OK, I see... You probably mean that since your sub-select occurs on two tables, those have to be present in the FROM clause. I've tested this

[sqlalchemy] Re: count function problem

2007-03-15 Thread jose
Glauco wrote: Michael Bayer ha scritto: On Mar 14, 2007, at 12:49 PM, Glauco wrote: This is perfect but when i try to use count function the SQL composer try to do an expensive sql. In [63]: print select([tbl['azienda'].c.id], tbl['azienda']).count() *SELECT count(id) AS

[sqlalchemy] SA skips integrity referential?

2007-02-16 Thread Jose Soares
Hi all, I wonder how SA could delete a row of my table (postgresql) linked with another table. Take a look... pg= select * from attivita where cod_specie='33'; codice | descrizione | cod_specie

[sqlalchemy] Re: SA skips integrity referential?

2007-02-16 Thread jose
my tables thus I don't know how to add nullable=False to my tables. jo On 2/16/07, *Jose Soares* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi all, I wonder how SA could delete a row of my table (postgresql) linked with another table. Take a look

[sqlalchemy] Re: SA skips integrity referential?

2007-02-16 Thread jose
Jonathan Ellis wrote: On 2/16/07, jose [EMAIL PROTECTED] wrote: Gary Bernhardt wrote: Referential integrity isn't being violated here - SA is nulling the foreign key before deleting the row it points to. Try adding nullable=False to the declaration of attivita.cod_specie

[sqlalchemy] Re: SA skips integrity referential?

2007-02-16 Thread jose
Jonathan Ellis wrote: On 2/16/07, jose [EMAIL PROTECTED] wrote: Jonathan Ellis wrote: Guess it would surprise you to learn about the SQL 92 ON DELETE SET NULL functionality too. :) Seems to me the SQL92 'ON DELETE SET NULL' is an explicit functionality, instead in our

[sqlalchemy] Re: SA skips integrity referential?

2007-02-16 Thread jose
jose wrote: Jonathan Ellis wrote: On 2/16/07, jose [EMAIL PROTECTED] wrote: Jonathan Ellis wrote: Guess it would surprise you to learn about the SQL 92 ON DELETE SET NULL functionality too. :) Seems to me the SQL92 'ON DELETE SET NULL

[sqlalchemy] Re: SA skips integrity referential?

2007-02-16 Thread jose
Michael Bayer wrote: On Feb 16, 2007, at 3:46 PM, jose wrote: No Jonathan, I don't want this column is set as NOT NULL, I have to allow null values for this column and I don't want enable the ON DELETE SET NULL functionality. I would like SA have the same behavior as PostgreSQL has, I like

[sqlalchemy] FlushError: Can't change the identity of instance

2007-02-08 Thread jose
Hi, Could please, someone tell me what the following error means? FlushError: Can't change the identity of instance [EMAIL PROTECTED] in session (existing identity: (class 'sicer.model.fatturazione.Prestazione', (6,), None); new identity: (class 'sicer.model.fatturazione.Prestazione',

[sqlalchemy] iteration over mapper

2007-01-31 Thread Jose Soares
Hi all, Probably this is a stupid question, :-[ but I don't understand how to iterate an object mapper to get fields value. --- user = session.query(User).select(id=1) for j in user.c: print j.name logname id password for j in user.c: print j.value 'Column' object has no attribute

[sqlalchemy] date format

2007-01-31 Thread Jose Soares
Hi all, I would like to display my dates with format '%d/%m/%Y' instead of ISO format. qry = session.query(Nazione).select(Nazione.c.codice=='201') qry[0].data_inizio print qry[0].data_inizio 2006-01-14 Is there a way to set it in SA without using a customer function ? jo

[sqlalchemy] Re: InvalidRequestError: This transaction is inactive

2007-01-24 Thread Jose Soares
Jose Soares ha scritto: Michael Bayer ha scritto: not sure about that, i thought maybe the multiple flush()es are breaking something but I just added a test case and it doesnt reproduce. make sure youre on the most recent versions since that was broken a few versions back

[sqlalchemy] serial

2007-01-24 Thread Jose Soares
Hi all, I would like to know how the postgresl serial type field works in sa? SA doesn't increment the serial column if of my group_permission table: gp=GroupPermission() for x in Permission.select(): gp.cod_ruolo = 'sysadmin' gp.cod_permesso = x.codice session.save(gp) print

[sqlalchemy] Re: serial

2007-01-24 Thread Jose Soares
INTO (cod_ruolo, cod_permesso ) VALUES (%(cod_ruolo)s, %(cod_permesso)s); because it is a postgresql responsability to assign value to id where serial is triggered. jo Jose Soares ha scritto: Hi all, I would like to know how the postgresl serial type field works in sa? SA doesn't increment

[sqlalchemy] transactions

2007-01-20 Thread jose
Hi all, I have a question about transactions I need to insert data into two tables (anag and user), sice I need to insert the generated primary key of anag into user. I have to flush anag to have the id to insert into user table. What happens if there's an interruption in the middle of

[sqlalchemy] Re: transactions

2007-01-20 Thread jose
Jonathan Ellis wrote: yes, you should, and your commented-out code looks fine thank you, Jonathan. On 1/20/07, jose [EMAIL PROTECTED] wrote: Hi all, I have a question about transactions I need to insert data into two tables (anag and user), sice I need to insert the generated

[sqlalchemy] Re: Column aliases

2007-01-19 Thread Jose Soares
I think I have a similar trouble, although the symptoms are different. I have a PostgreSQL table named 'acl' mapped as UserGroup. Table acl Column| Type --+- id | integer id_operatore | integer cod_ruolo| text id_asl | integer id_azienda

[sqlalchemy] Re: Column aliases

2007-01-19 Thread jose
the attribute on the class: mapper(Class, table, properties={ 'id':table.c.id, 'name':synonym('id', proxy=True) }) where both id and name utlimately point to just the id information on the class. On Jan 19, 2007, at 9:48 AM, Jose Soares wrote: I think I have a similar trouble

[sqlalchemy] Re: how to find out the last insert id ?

2007-01-19 Thread jose
Michael Bayer wrote: dischdennis wrote: what is the easiest way to find out the last insert id? (MySQL 5) supplast = select([func.last_insert_id()],app_schema.SupplierTable.c.pr_supplier_ID 0).execute().fetchone()[0] does not work for some reason Dennis result =

[sqlalchemy] Re: Saving all transactions against a database (logging queries?)

2007-01-05 Thread jose
Hello Barry, I'm trying to get logging work...I put in my model.py the following code and I expected to see my queries into /tmp/sa.log file, but... what's wrong with it? from turbogears import database from sqlalchemy import Table, relation from sqlalchemy.engine import create_engine from

[sqlalchemy] Re: left join help

2007-01-04 Thread Jose Soares
Hello Michael, the query is perfect, with every JOIN and LEFT JOIN, thank you very much. jo Michael Bayer ha scritto: hey jose - was waiting to see if anyone jumped on this for you. alas, no responses. making some assumptions about your Table objects, your query above would look something

[sqlalchemy] how to rename labels?

2006-12-28 Thread jose
the following query... session.query(Comune).options(eagerload('provincia')).select(and_(Provincia.c.nome=='MODENA',Provincia.c.codice==Comune.c.cod_provincia),order_by=Provincia.c.nome, limit=10) generate this cose: INFO SELECT comune.cod_provincia AS comune_cod_provincia,

[sqlalchemy] Re: how to rename labels?

2006-12-28 Thread jose
Lee McFadden wrote: On 12/28/06, jose [EMAIL PROTECTED] wrote: I would like to know how assign label names as in: comune.cod_provincia AS sigla_provincia instead of: comune.cod_provincia AS comune_cod_provincia http://www.sqlalchemy.org/docs/sqlconstruction.myt#sql_select_labels I

[sqlalchemy] Re: how to rename labels?

2006-12-28 Thread jose
Lee McFadden wrote: On 12/28/06, jose [EMAIL PROTECTED] wrote: I Lee, I see this examples works only with table object. Is there a way to use it with class mappers? If you're using the class mappers I'm not quite sure why you'd need to fiddle with the labels - you shouldn't even need

[sqlalchemy] Re: startswith/endswith and bindparam error

2006-12-27 Thread jose
Michael Bayer wrote: the startswith/endswith functions are just sticking a % on either side of a string argument and using LIKE. im not exactly sure how they could accept a bindparam argument since there is a string concatenation that must take place within the python space. Since the

[sqlalchemy] Re: How do I do append_whereclause() using the ORM?

2006-12-18 Thread Jose Soares
Robin Munn ha scritto: Maybe this is in the documentation, but if so, I've missed it. I'd like to do something like the stmt = users.select(); stmt.append_whereclause(...) example found in http://www.sqlalchemy.org/docs/sqlconstruction.myt#sql_building , but using a Query object taken from

[sqlalchemy] unicode

2006-12-14 Thread jose
Hi all, I'm trying to insert UTF8 characters (like this: perchè) in PostgreSQL but... File build/bdist.linux-i686/egg/sqlalchemy/orm/attributes.py, line 589, in __init__ File build/bdist.linux-i686/egg/sqlalchemy/orm/attributes.py, line 51, in is_equal File

[sqlalchemy] Re: unicode

2006-12-14 Thread jose
Marco Mariani wrote: Lee McFadden wrote: Going from the line number in your exception that would be because your columns are of type String. Change the columns to Unicode and it should solve your problem. foo_table = Table('foo', metadata, Column('id', Integer, primary_key=True),

[sqlalchemy] Re: CASE , CAST, COALESCE

2006-12-13 Thread Jose Soares
Great! jo Michael Bayer ha scritto: we have case(): select(case([(table.c.x==5, 5), (table.c.y==7, 12)], else_=7)) and cast(): select([cast(table.c.x, Numeric)]) which are in the generated documentation for sql.py. for coalesce() you can call that as func.coalesce() for now.

  1   2   >