Hi all,
I would like to create a python customer function to extract data from a
table column and return a calculated value as in:
def birth(data):
mm =
dict(A='01',B='02',C='03',D='04',E='05',H='06',L='07',M='08',P='09',R='10',S='11',T='12')
return '19'+data[6:8] +'-'+
Hi Glauco, I'm glad to hear you. :-)
Yes, you were right, I really forgot to register the function.
I'll see you around.
j
Glauco wrote:
Il 10/02/2015 09:33, jo ha scritto:
Hi all,
I can't realize how to create a sql custom function. I need to
transform a string column value into a number
table1.somelongcolumn AS
table1_somelong_7.
On Monday, January 12, 2015 at 3:09:22 PM UTC+3:30, jo wrote:
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
Do you suggest to use server_default instead of DefaultClause in all cases?
j
Il giorno giovedì 8 gennaio 2015 15:17:20 UTC+1, Michael Bayer ha scritto:
use server_default with text() as documented at
http://docs.sqlalchemy.org/en/rel_0_9/core/defaults.html#server-side-defaults.
jo
Hi all,
I have a problem with DefautClause. I need to assign a default to a
numeric column.
tbl['rischio_attivita'] = Table('rischio_attivita', database.metadata,
Column('id', Integer, Sequence('rischio_attivita_seq'),
primary_key=True),
Column('cod_attivita',
Yes, it works, now!
Thanks a lot, Jonathan
j
Il giorno giovedì 20 novembre 2014 19:35:03 UTC+1, Jonathan Vanasco ha
scritto:
SqlAlchemy returns column results as a `KeyedTuple`. It's similar to
`collections.namedtuple` in the standard library
Looking at your code, my guess is that you
I all,
I got a KeyedTuple error that I don't know what it means or how to solve it.
Could anyone give me some help?
Thanks.
I'm using SQLAlchemy-0.9.3-py2.6.egg
ProgrammingError: (ProgrammingError) can't adapt type 'KeyedTuple' 'SELECT
unita_aziendale.id AS unita_aziendale_id,
It works. Thanks a lot, Jonathan.
j
Jonathan Vanasco wrote:
I asked a similar question a few days ago; it's still on the front
page of the group. Mike replied to that and gave some details
Your query would be something like:
class A(Base):
that keyword.
On May 27, 2013, at 7:17 AM, jo jose.soa...@sferacarta.com
mailto:jose.soa...@sferacarta.com wrote:
I have not been able to solve the problem
can someone please help me?
...
database.bind_meta_data()
File
/home/jose/buildout/eggs/TurboGears-1.1.3-py2.6.egg/turbogears/database.py
for a line of the form
sqlalchemy.max_overflow = X and delete it.
Hope that helps,
Simon
On Tue, May 28, 2013 at 10:34 AM, jo jose.soa...@sferacarta.com wrote:
Thanks for the tip, Michael, I'm going to see how to manage with this
keyword (because I'm not specify such parameter, but probable
I have not been able to solve the problem
can someone please help me?
...
database.bind_meta_data()
File
/home/jose/buildout/eggs/TurboGears-1.1.3-py2.6.egg/turbogears/database.py,
line 73, in bind_metadata
metadata.bind = sqlalchemy.create_engine(dburi, **alch_args)
File
|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 (partition by col1 order by col2 asc)
from tmp;
How can I do such query in sqlalchemy?
Thanks for any help.
j
Hi all,
I'm trying to use turbogears and sqlite as:
sqlalchemy.dburi=sqlite://
but I got this error:
TypeError: Invalid argument(s) 'max_overflow' sent to create_engine(),
using configuration SQLiteDialect_pysqlite/SingletonThreadPool/Engine.
Please check that the keyword arguments are
Hi all,
I'm running an web application in turbogears1 using sqlalchemy I'm using mainly postgresql as database
but in a few installations I'm using oracle (same programs only db change).
Using PostgreSQL all is ok but when I use
oracle some times I get the following error:
File
_tuple() is fine,
Thanks Michael :-)
j
Michael Bayer wrote:
On Jan 3, 2013, at 2:40 AM, jo wrote:
Hi all,
I need to use in_(), but in oracle it has a limit of 1000 values,
there's an alternative syntax that can be used successful in oracle and it is:
(field,-1) in ( (123,-1), (333,-1
Hi all,
I need to use in_(), but in oracle it has a limit of 1000 values,
there's an alternative syntax that can be used successful in oracle and
it is:
(field,-1) in ( (123,-1), (333,-1), ... )
I tryed this:
session.query(Mytable).filter((Mytable.c.id,-1).in_([(123,-1),(333,-1)]) )
Hi all,
Someone could help me with this query?
SELECT MAX(CAST(SUBSTR(codice_aziendale, 2) AS INTEGER)) FROM azienda
WHERE codice_aziendale LIKE '#%%' AND
REGEXP_LIKE(SUBSTR(codice_aziendale, 2) , '[[:digit:]]')
I'm trying in this way:
database you're using. It's likely your DB doesn't
support REGEXP_LIKE.
On Apr 18, 2012, at 4:00 AM, jo wrote:
Hi all,
Someone could help me with this query?
SELECT MAX(CAST(SUBSTR(codice_aziendale, 2) AS INTEGER)) FROM azienda WHERE
codice_aziendale LIKE '#%%' AND REGEXP_LIKE(SUBSTR
'),
ScadenzaMalattia.c.id_unita_aziendale == 2,
ScadenzaMalattia.c.cod_malattia == '012'))
On Apr 13, 2012, at 1:59 AM, jo wrote:
Thanks Michael, your explanation is comprehensive, currently I'm using both of
them,
but I feared that one of them could become obsolete in the future
Hi all,
I'm sorry for this simple question.
What's the difference between query and select ?
are they interchangeable?
which of the two, it is best to use?
--- print(session.query(Azienda.c.data_inizio).limit(1))
SELECT azienda_data_inizio
FROM (SELECT azienda.data_inizio AS
and can get back any combination of objects/tuples.
I know it's not 100% pure but it does seem to work out pretty well.
On Apr 12, 2012, at 2:06 PM, jo wrote:
Hi all,
I'm sorry for this simple question.
What's the difference between query and select ?
are they interchangeable?
which
This is the way I solved the problem... (how to backup a table row into
another table before delete or update it) ...if it can help:
from sqlalchemy.orm import MapperExtension
class History(MapperExtension):
def __init__(self):
MapperExtension.__init__(self)
self.methods =
Hi all,
I found a difference between Oracle and PostgreSQL about datetime objects.
Using the engine Oracle returns every date column as datetime.datetime
while PostgreSQL returns it as datetime.date
I have a table with a column data_inizio defined as DATE in table
tariffa in my db.
take a
shinriyo wrote:
hi jo
Oracle and PostgreSQL are different.
Oracle also have hour and minutes and second.
If you want minutes and second on PostgresQL, you should use datetime.
Hi shinryo,
I don't want hours and minutes.
My problem is that I have a comparison in my code like
Hi all,
I don't know how to fix this error in my model:
sqlalchemy.exc.ArgumentError: Could not determine join condition between
parent/child tables on relationship RuoloPermesso.permessi. Specify a
'primaryjoin' expression. If 'secondary' is present, 'secondaryjoin' is
needed as well.
It works!
Thanks a lot, Tate.
j
Tate Kim wrote:
Hi, jo.
At first, try with cascade option 'all, delete'
(note that dropped 'delete-orphan').
Second, I've ever been your situation before, maybe
-Original Message-
From: jo jose.soa...@sferacarta.com
Sender: sqlalchemy
Hi all,
I'm trying to delete cascade a linked row without success.
Could anyone give me some help?
This is my mapper:
mapper(Azienda,
tbl['azienda'],
properties = {
'anagrafica': relation(Anagrafica, cascade='all, delete,
delete-orphan'),
})
the table Azienda
In cx_oracle mailing list, they suggested me, this:
... write your own equivalent of makedsn, which really ought not be too hard.
You'd want to emit something like this:
I solved the problem using this monkeypatch to makedsn as suggested me
by Christoph Zwerschke.
makedsn = cx_Oracle.makedsn
cx_Oracle.makedsn = lambda *args, **kw: makedsn(*args,
**kw).replace('SID','SERVICE_NAME')
Thaks any way to everyone.
j
Michael Bayer wrote:
yeah I dunno, the
, which would then let you avoid generating the dsn in
software
-- craig
Michael Bayer wrote:
is that a known bug in cx_Oracle ?
On Dec 16, 2011, at 4:45 AM, jo wrote:
I solved the problem using this monkeypatch to makedsn as suggested me by
Christoph Zwerschke.
makedsn
Michael Bayer wrote:
On Dec 16, 2011, at 10:31 AM, jo wrote:
I don't know Michael, only that Craig Hagan in oracl...@freelists.org,
suggested me this workaround...
...However, I'm pretty sure that the problem is that you're depending upon
service names for your connection to succeed
', port = 1521, service_name = 'mydb')
j
On Dec 16, 2011, at 4:45 AM, jo wrote:
I solved the problem using this monkeypatch to makedsn as suggested me by
Christoph Zwerschke.
makedsn = cx_Oracle.makedsn
cx_Oracle.makedsn = lambda *args, **kw: makedsn(*args,
**kw).replace('SID
Hi all,
I have this definition of a table.
session = Table('session', database.metadata,
Column('id', Unicode(40), primary_key=True, nullable=False),
Column('data', Text),
Column('expiration_time', TIMESTAMP(timezone=False)),
)
In the PostgreSQL DB, it
Yes, Ian, it works, :-)
thank you
j
Ian Kelly wrote:
On Fri, Dec 3, 2010 at 4:08 AM, jo jose.soa...@sferacarta.com wrote:
Hi all,
I'm trying to write a GROUP BY query grouped by a function (to_char) using a
variable format, which could be 'yy' or ''
as in:
sql=session.query
Hi all,
I'm trying to write a GROUP BY query grouped by a function (to_char)
using a variable format, which could be 'yy' or ''
as in:
sql=session.query(
func.to_char(Prestazione.c.data,format),
func.sum(Prestazione.c.quantita).label('quantita'),
Michael Bayer wrote:
On May 19, 2010, at 5:34 AM, jose soares wrote:
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
Hi all,
In version 0.6 seems the group_by property does nothing...
(Pdb) sql =
select([Verifica.c.codice,func.sum(Prestazione.c.importo).label('importo')])
(Pdb) print sql
SELECT verifica.codice, sum(prestazione.importo) AS importo
FROM verifica, prestazione
(Pdb)
Lance Edgar wrote:
On 4/27/2010 5:22 AM, jo wrote:
Hi all,
In version 0.6 seems the group_by property does nothing...
(Pdb) sql =
select([Verifica.c.codice,func.sum(Prestazione.c.importo).label('importo')])
(Pdb) print sql
SELECT verifica.codice, sum(prestazione.importo) AS importo
FROM
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 insert a new one,
King Simon-NFHD78 wrote:
Jo wrote:
[SNIP]
and-
In [13]: aa=Anagrafica.get(111)
In [14]: aa.delete()
In [15]: aa.flush()
-
but in version 0.6 I can't find
nd flushing it
and then insert GestioneDocFile assigning
CatalogazioneModulistica.numero_catalogo to
GestioneDocFile.numero_catalogo_catalogazione ?
j
jo wrote:
King
Simon-NFHD78 wrote:
Jo wrote:
[SNIP]
and-
Hi all,
Module sqlalchemy.engine.base:*1180* in |__execute_context
||context*.*parameters*[**0**]**,* context*=*context*)*|
Module sqlalchemy.engine.base:*1249* in |_cursor_execute||
self*.*_handle_dbapi_exception*(*e*,* statement*,* parameters*,*
cursor*,* context*)*|
Module
Hi all,
I'm trying migrate from 0.3 to 0.6
I don't know how to delete an object
in the old version it was:
My.get(1).delete()
in 0.6:
My.get(1).delete()
AttributeError: 'My' object has no attribute 'delete'
j
--
Jose Soares
Sferacarta Net
Via Bazzanese 69
40033 Casalecchio di Reno
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
--
You received this message because you are subscribed to the Google Groups
It works, thank you, Fernando. :-)
j
Fernando Takai wrote:
Hi,
You can try:
My.query.filter_by(id=id).delete()
(If your object can use the .query syntax)
or
session.query(My).filter_by(id=id).delete()
On Apr 13, 2010 6:12 AM, jo jose.soa...@sferacarta.com
mailto:jose.soa...@sferacarta.com
Michael Bayer wrote:
jose soares wrote:
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
this is the 0.3 syntax, and now it works.
class MyType(TypeDecorator):
impl = Numeric
def convert_bind_param(self, value, engine):
return decimal.Decimal(str(value))
def convert_result_value(self, value, engine):
return decimal.Decimal(str(value))
Thank you very much, Michael. :-)
j
jo wrote
Here another difference between Oracle and PostgreSQL
The SQLAlchemy.func.max() on a column date, returns a datetime.date in
pg but a datetime.datetime in oracle...
Why this difference?
take a look:
Bolletta = Table('bolletta', database.metadata,
Column('id', Integer, nullable=False,
Michael Bayer wrote:
jo wrote:
Here another difference between Oracle and PostgreSQL
The SQLAlchemy.func.max() on a column date, returns a datetime.date in
pg but a datetime.datetime in oracle...
Why this difference?
Oracle doesn't have a "date" type.this
Hi all,
I have some troubles creating my db schema with Oracle. The problem is
on this column:
Column('cod_caratteristica_rischio', Unicode(10), index=True,
nullable=False)
It works fine in PostgreSQL but when I try it on Oracle sa tries to
create an index with a name too long ( 30 char).
I see, thank you, Mariano.
j
Mariano Mara wrote:
Excerpts from jo's message of Tue Mar 30 03:25:18 -0300 2010:
Hi all,
I have some troubles creating my db schema with Oracle. The problem is
on this column:
Column('cod_caratteristica_rischio', Unicode(10), index=True,
nullable=False)
Hi all,
I'm trying to solve this error...
File
/home/sfera/release/sicer/BASE/controller/controlli/sopralluogo.py,
line 645, in verifiche
Piano.c.data_inizio =data.get('data_sop') ,
File /usr/lib/python2.4/site-packages/sqlalchemy/sql.py, line 1294, in
__le__
return self._compare('=', other)
Mike Conley wrote:
On Tue, Dec 22, 2009 at 2:34 AM, jo jose.soa...@sferacarta.com
mailto:jose.soa...@sferacarta.com wrote:
Hi all,
I'm trying to solve this error...
File
/home/sfera/release/sicer/BASE/controller/controlli/sopralluogo.py,
line 645, in verifiche
Hia all,
I'm dogged by this error for months,
could someone, please, explain me what it means and how to avoid it.
File /usr/lib/python2.4/site-packages/sqlalchemy/orm/attributes.py, line
532, in __getitem__
return self.data[i]
IndexError: list index out of range
thanks for any help.
Hi all,
I'm trying migrate from 0.3.10 to 0.4 and there's the following error:
... engine = database.metadata.engine
AttributeError: 'MetaData' object has no attribute 'engine'
I was reading the section 0.3 to 0.4 Migration of
state before flushing it?
j
On May 20, 2009, at 1:45 AM, jo wrote:
Hello all,
I have the following problem.
While I'm working in my session, someone change my instance identity.
I would like to avoid this.
Is there a way to understand if was there any change before flushing
Glauco wrote:
jo ha scritto:
Michael Bayer ha scritto:
that is your own application changing the primary key of a loaded
instance, which is a feature very old versions of SQLAlchemy did not
support. Upgrade to any recent version of 0.4 or 0.5 and you wont
have
Michael Bayer wrote:
On May 21, 2009, at 2:04 AM, jo wrote:
Michael Bayer ha scritto:
that is your own application changing the primary key of a loaded
instance, which is a feature very old versions of SQLAlchemy did not
support. Upgrade to any recent version of 0.4 or 0.5
Hello all,
I have the following problem.
While I'm working in my session, someone change my instance identity.
I would like to avoid this.
Is there a way to understand if was there any change before flushing?
This is the message:
File
Michael Bayer ha scritto:
On Mar 19, 2009, at 12:34 PM, jo wrote:
Michael Bayer wrote:
why dont you just stick with None instead of nn ? then you just
write:
if v is None:
clause.append(self.c.field != v)
else:
clause.append(self.c.field == v)
It could
Hi all,
I would like to know if there's a notnull() function in sqlalchemy
similar to null()
to avoid things like not_(null()) ?
thank you
j
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To
:
well usually null() and not_(null()) aren't needed as explicit
constructs.comparisons like somecol == None and somecol != None
will generate the appropriate NULL/NOT NULL expression.
On Mar 19, 2009, at 4:48 AM, jo wrote:
Hi all,
I would like to know if there's a notnull
))
that's 3 lines more ..
svil
On Thursday 19 March 2009 17:43:22 jo wrote:
Well, MIchael, in my case a notnull() function could be very
interesting because I'm using it in a function, and would like pass
values as parameters in such way:
def search( self, **kw ):
by_where_clause
) :-(
and null() = IS NULL
j
On Mar 19, 2009, at 11:43 AM, jo wrote:
Well, MIchael, in my case a notnull() function could be very
interesting because
I'm using it in a function, and would like pass values as parameters
in such way:
def search( self, **kw ):
by_where_clause
connections is likely creating a deadlock, and in any case violates
the integrity of the transaction.
On Mar 7, 2009, at 1:26 PM, jo wrote:
Hi all,
I have a strange behavior using MapperExtension before_update.
I created two tables; anag and azi, azi have a foreign key to anag.
When
Hi all,
I have a strange behavior using MapperExtension before_update.
I created two tables; anag and azi, azi have a foreign key to anag.
When I try to change some column value on anag table the
HistoryAnag.before_update is correctly triggered and it returns EXT_PASS,
but when I try to change
Hi all,
I wonder what this message mean:
TimeoutError: QueuePool limit of size 5 overflow 10 reached, connection timed
out, timeout 30
any ideas?
jo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy
You cannot pass currval('users_user_id_seq') as a parameter value, you
have to pass an integer value instead.
I solved this problem in this way:
INSERT INTO employees
(employee_user_id, employee_id, employee_first_name,
employee_last_name, employee_address, employee_city, employee_state,
Michael Bayer ha scritto:
On Jan 2, 2009, at 11:51 AM, jo wrote:
Seems SA checks if table already exist in all_tables system table...
and creates it only if it doesn't exist.
In my case...
SQL select table_name from all_tables where
table_name='FUNZIONE_CALCOLO', returns:
TABLE_NAME
)
---
what's wrong ?
jo
ps:
I'm using SA 0.3.10
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalchemy
, \n\tPRIMARY KEY (id), \n\t
FOREIGN KEY(cod_funzione_calcolo) REFERENCES funzione_calcolo
(codice)\n)\n\n' {}
jo ha scritto:
hi all,
I'm having problems with database.metadata.create_all.
The code works perfectly with PostgreSQL but with Oracle it
doesn't...and it exits with the following
azienda.id = :azienda_id ORDER BY azienda.rowid' {'azienda_id': u'1'}
j
On Dec 11, 2008, at 12:01 PM, jo wrote:
Hi all,
I'm using SA with cx_Oracle. In some queries it raises the following
error:
File /usr/lib/python2.4/site-packages/sqlalchemy/engine/base.py,
line 581
Michael Bayer ha scritto:
On Dec 12, 2008, at 5:19 AM, jo wrote:
Michael Bayer ha scritto:
Look into using the Unicode type for python unicode values.
http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/types.html?highlight=unicode#sqlalchemy.Unicode
This is the 0.5
You are right, Michael,
1=0 works.
thank you,
j
Michael Bayer ha scritto:
I'd try 1 = 0 I dont think oracle has boolean keywords at least
last I checked...
On Dec 11, 2008, at 4:09 AM, jo wrote:
Hi all,
I'm trying sqlalchemy with Oracle. Seems Oracle doesn't understand
Hi all,
I'm using SA with cx_Oracle. In some queries it raises the following error:
File /usr/lib/python2.4/site-packages/sqlalchemy/engine/base.py, line 581,
in _execute_raw
self._execute(context)
File /usr/lib/python2.4/site-packages/sqlalchemy/engine/base.py, line 599,
in _execute
Maybe I'm using the 'case_sensitive' in a wrong way.
Here what I want to reach :
create unique index myname on mytable (lower(mycolumn));
How can I create it on sqlalachemy?
j
Glauco ha scritto:
jo ha scritto:
Hi all,
Trying to migrate from 0.3.10 to 0.5 I have this error
Hi all,
I created a table with the following column:
Column('last_updated', DateTime, PassiveDefault(func.current_timestamp
()), onupdate=func.current_timestamp())
Maybe I don't understand how onupdate works.
I would like to have this column to be changed every time the row is
updated,
but it
)
assign_mapper(context, Bolletta, tbl['bolletta'])
jo
--~--~-~--~~~---~--~~
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
78 matches
Mail list logo