Re: [sqlalchemy] nullable dates

2016-06-14 Thread Marco Correia
. Marco On Tuesday, June 14, 2016 at 1:46:19 PM UTC+1, Mike Bayer wrote: > > Let's do an MCVE: > > from sqlalchemy import * > from sqlalchemy.orm import * > from sqlalchemy.ext.declarative import declarative_base > > Base = declarative_base() > > > cla

[sqlalchemy] nullable dates

2016-06-14 Thread Marco Correia
_default=text("NULL")) but it makes no difference. Can someone help? Thanks! Marco -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalc

[sqlalchemy] subqueryload - off-by-one issue?

2016-05-12 Thread Marco
easily. Thanks! Marco -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to

Python3 error when running alembic upgrade head

2016-04-04 Thread Marco Falcioni
Hello, we are moving to python3 and we ran into the error - is there anything we should do differently? Thanks Marco (alembic==0.8.5) INFO [alembic.runtime.migration] Context impl MySQLImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. Traceback (most recent call last

[sqlalchemy] ORM/Inheritance: Puzzling behavior when trying to use a subclass in joined table inheritance

2015-07-30 Thread Marco
to it - this seems to be due to some module introspection done by the mapper that appears to be dependent on what modules are imported and in what order. I'll be happy to learn of better ways to achieve the same end goal. Cheers Marco -- You received this message because you are subscribed

[sqlalchemy] Re: SQLAlchemy: Table creation before data insertion?

2014-12-07 Thread Marco
Hi, straight from the docs: engine = create_engine('sqlite:///:memory:') metadata = MetaData() user = Table('user', metadata, Column('user_id', Integer, primary_key = True), Column('user_name', String(16), nullable = False), Column('email_address', String(60), key='email'),

pyc files left in version folder create ghost history

2014-03-13 Thread Marco Falcioni
below. (Python 2.7.2, Mac OS X) https://dl.dropboxusercontent.com/u/1980224/alembic_bug.tar.gz Cheers! Marco -- You received this message because you are subscribed to the Google Groups sqlalchemy-alembic group. To unsubscribe from this group and stop receiving emails from it, send an email

[sqlalchemy] sqlalchemy/orm/query.py line 3356

2014-03-13 Thread Marco
_ColumnEntity(query, c, namespace=column) if c is not column: return Cheers Marco -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email

[sqlalchemy] Re: sqlalchemy/orm/query.py line 3356

2014-03-13 Thread Marco
SQLA 0.9.3 On Thursday, March 13, 2014 5:09:51 PM UTC-7, Marco wrote: Hi, this line (in red) seems mis-indented: if not isinstance(column, expression.ColumnElement) and \ hasattr(column, '_select_iterable'): for c in column._select_iterable

[sqlalchemy] ForeignKeyConstraint error

2013-05-08 Thread Marco De Felice
Hi on sqlalchemy 0.7.4 Using ForeignKeyConstraint it happens that join() or outerjoin() does not find foreign keys while using ForeignKey on field declaration works (see attachment), is this a nomal sa behaviour? Thanks -- You received this message because you are subscribed to the Google

[sqlalchemy] Self-referencing many-to-many with the same backref

2012-02-02 Thread Marco Flores
Hello, everyone. I can't find anythin on the we regarding this subject, here's a snippet of my code: friendship = Table( 'friendships', Base.metadata, Column('friend_a_id', Integer, ForeignKey('users.id'), primary_key=True), Column('friend_b_id', Integer, ForeignKey('users.id'),

[sqlalchemy] Re: SQL: using BETWEEN with char fields

2011-04-25 Thread Marco
to write stored procedures for doing this inline within a query, but each query would trigger a table scan and perform poorly. I would love to know if I am wrong, as this is an issue that I will also need to resolve. Marco On Apr 24, 5:15 am, Andrew Volozhanin linuxhead...@gmail.com wrote: Hello

[sqlalchemy] 2 transactions for one

2010-06-06 Thread marco vaccari
This script lock in the update statement following select for update: eng=sqlalchemy.create_engine('postgres://x.loc/db') metadata=sqlalchemy.MetaData() metadata.bind=eng tab1 = Table('tab1', metadata, autoload=True) a_rec = tab1.select( for_update=True

[sqlalchemy] Re: inner join and ambiguous columns

2010-03-22 Thread marco vaccari
Sorry. I speak english in rare occasions. No. It is not an insert into a join. The result of a join between tables A and B is the VALUES partial set for an insert into table C. sql = A.join(B).select(A.c.id == an_id, fold_equivalents=True, use_labels=False) rec = sql.execute().fetchone()

[sqlalchemy] inner join and ambiguous columns

2010-03-19 Thread marco vaccari
no more correspond to the originals and then to the table C columns labels. I am new to sqlalchemy. Is there a better solution ? Can I avoid fold_equivalents in this case? Thanks! Marco Vaccari -- You received this message because you are subscribed to the Google Groups sqlalchemy group

[sqlalchemy] Re: inner join and ambiguous columns

2010-03-19 Thread marco vaccari
Opsss! dict(zip(record.keys(), record.items()) must be dict(record.items()) On 19 Mar, 16:23, marco vaccari agat...@gmail.com wrote: Consider 3 tables A,B,C A JOIN B ON A.id = B.id produce all the columns required for an insert into C. I can write: C.insert().values(dict(zip(record.keys

Re: [sqlalchemy] two updates fired when querying related tables?

2010-02-03 Thread Marco De Felice
Michael Bayer ha scritto: Marco De Felice wrote: Hi all This unusual problem appeared today. I have a mapper extension that gets called twice if I do a query on a relate_table while updating properties of a mapped object. I do something like this: myObj = myMappedObject session.begin

Re: [sqlalchemy] two updates fired when querying related tables?

2010-02-03 Thread Marco De Felice
By the way, I just wanted to let you know that while I don't usually use this mailing list, we're on the way to have a gui application used on production that uses sqlalchemy and it all works very well (also considering the little time I have to study SA, I just use it) -- You received this

[sqlalchemy] getting a numpy recarray from a sqlalchemy query

2009-10-16 Thread Giovanni Marco Dall'Olio
Hi, I think it would be cool to have an option to obtain the results of a sqlalchemy query as a numpy's recarray, instead of a list of tuples as it is now. Examples: data = session.query(People.name, People.surname, People.apples, People.pears).as_recarray() data['name'] Albert Mario Luigi

[sqlalchemy] query on related: speed problems with huge table

2009-05-14 Thread Marco De Felice
Hi I have a huge Agents table with many relations and a Orders table with agent field related via r_agent to Agents. When I filter like orders.r_agent.has(Agents.name.ilike(test)) the query is too slow. I came up with creating a view Agents_small on the database Agents table whith only a few

[sqlalchemy] Re: query on related: speed problems with huge table

2009-05-14 Thread Marco De Felice
Michael Bayer ha scritto: Is the solution that you created a new table which is receiving a copy of some rows (essentially materialized view) ? otherwise I don't see what is allowing a speed change. Thanks, that confirms my suspects. There's some problem elsewhere in my code.

[sqlalchemy] Re: SQLAlchemy and unit tests

2009-05-12 Thread Giovanni Marco Dall'Olio
On Tue, May 12, 2009 at 4:54 AM, James rent.lupin.r...@gmail.com wrote: So: - what is the recommended database initialisation / cleanup strategy for unit tests involving SA? - can anyone suggest how ORM state could be hanging around between unit tests (I'm using an in-memory DB)? - is there

[sqlalchemy] Re: filter Association and order the union via Orm?

2008-10-06 Thread Marco De Felice
Michael Bayer wrote: the most straightforward way is to have Parent/Child descend from a common base class and use concrete table inheritance in conjunction with polymorphic_union, as described in :

[sqlalchemy] filter Association and order the union via Orm?

2008-10-03 Thread Marco De Felice
given the structure below (pasted from SA 0.5 docs of association object): left_table = Table('left', metadata, Column('id', Integer, primary_key=True), Column('l_data', String(50)) right_table = Table('right', metadata, Column('id', Integer, primary_key=True), Column('r_data',

[sqlalchemy] 0.4 to 0.5 beware of session.close ?

2008-08-22 Thread Marco De Felice
While migrating I came across the following sequence of actions, I had some old code that called session.close() elsewhere in the application and also I tend to use sqlalchemy as a temporary object cache knowing this is somewhat discouraged. Anyway is it correct that nothing happens when calling

[sqlalchemy] Audit log client side

2008-02-22 Thread Marco De Felice
Hi I'm thinking about a simple client side table audit with SA. Given the audit log pattern: http://martinfowler.com/ap2/auditLog.html wouldn't it be simple to adapt it to a mapped class? I was thinking of a log() function inside the mapped class that if called saves data into a second table

[sqlalchemy] Re: SessionExtension and Transactions: how to coordinate all SessionExtension funcs

2007-12-10 Thread Marco Mariani
Stefano Bartaletti wrote: I need to gather IDs in after_commit because theID is a serial Postgres value that is available only after flush() Not really... in postgres, you can ask to consume the next sequence value with SELECT NEXTVAL('sequence_name') and explicitly set that as primary

[sqlalchemy] Re: column_property() caching

2007-12-04 Thread Marco Mariani
Vladimir Iliev wrote: hi, is it possible to add a non-caching column_property() to my mapping? You can use expire() on a single column, so you could proxy that column with a @property that also expires it. -- This e-mail (and any attachment(s)) is strictly confidential and for use only

[sqlalchemy] Re: features: database drivers and ssl

2007-11-15 Thread Marco Mariani
Rick Morrison wrote: Hi Marco, [...] Thank you. Very helpful. --~--~-~--~~~---~--~~ 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

[sqlalchemy] features: database drivers and ssl

2007-11-14 Thread Marco Mariani
I need to evaluate a third-party application, that will be integrated with others by one of my programs. My integration app runs on linux with SA 0.4, and I will strive to use the latest stable release. I need to write a couple of requirements to choose the third-party application. Will I

[sqlalchemy] Re: mapper

2007-11-06 Thread Marco Mariani
lur ibargutxi wrote: 'idindicatorgroupcontainer' : relation(IndicatorGroups, primaryjoin=sql.and_(IndicatorGroups.idindicatorgroup==GroupGroups.idindicatorgroupcontainer)),'idindicatorgroupcontained' : relation(IndicatorGroups,

[sqlalchemy] Re: mapper

2007-11-06 Thread Marco Mariani
lur ibargutxi wrote: I forgot. Try using tables instead of classes that are not mapped yet.. mappers['groupgroups'] = mapper(GroupGroups, tables['groupgroups'], properties = { 'idindicatorgroupcontainer' : relation(IndicatorGroups,

[sqlalchemy] Re: turbogears, sqlalchemy and utf8

2007-10-23 Thread Marco Mariani
Lukasz Szybalski wrote: dev.cfg has sqlalchemy.dburi=mysql://user:[EMAIL PROTECTED]:3306/dbname sqlalchemy.convert_unicode = True --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post

[sqlalchemy] Re: TurboGears: best practices for SELECTing

2007-10-11 Thread Marco Mariani
James Brady ha scritto: Hi Marco, assign_mapper did help - the relations are now accessible through my models, and the query syntax is nicer than pure SA as well in my opinion. However, I'm using the identity framework (part of TurboGears) Me too. which unfortunately doesn't play nicely

[sqlalchemy] Re: TurboGears: best practices for SELECTing

2007-10-10 Thread Marco Mariani
James Brady ha scritto: The problem I'm hitting at the moment is how to properly select simple objects... There seems to be two main approaches, for example: session.query(Ownership).select() or ownership_table.select().execute() With the first approach, I get InvalidRequestError: Parent

[sqlalchemy] Re: insert() on compound key-how to auto number second key

2007-09-08 Thread Marco Mariani
Lukasz Szybalski ha scritto: I am trying to insert a record with a compound primary key that consists of Team_Sid, User_Sid I can either do i = users_table.insert() i.execute(TEAM_SID=343, USER_SID=1,TEAM_NAME='the team') i.execute(TEAM_SID=343, USER_SID=2,TEAM_NAME='the team')

[sqlalchemy] Re: creating a database through SQLAlchemy

2007-09-03 Thread Marco Mariani
Travis Kriplean ha scritto: However, this seems a bit ugly. Is there a way to obtain a non- transactional connection from an engine in 0.3.10? If not, is it possible in 0.4? I use this with SA 0.3.10 and Postgres:

[sqlalchemy] SA 0.4 orm mapped class 'instrumentation time'

2007-08-30 Thread Marco De Felice
Michael Bayer ha scritto: its most likely uncompiled mappers. the c attribute on the class is deprecated; use Table.attribute instead. ... Thanks, but it seems the Table.c.attribute has a .op() method that I can't find on Table.attribute

[sqlalchemy] SA 0.4 orm mapped class 'instrumentation time'

2007-08-29 Thread Marco De Felice
With SA 0.4beta4 if I try to access a mapped object field (Table.c.fieldname) before any query has been sent to the database the call fails with a AttributeError(key). Everything works if I do this after having issued a query. -- Example: (skip to the __main__ section) import sqlalchemy as sqa

[sqlalchemy] Re: sqlalchemy with turbogears and mapper-part2 connect and select

2007-08-20 Thread Marco Mariani
Lukasz Szybalski ha scritto: Got another error here. but I guess its fixed in a newer version of sqlalchemy via ticket 482 Yes. I wasn't aware of 482 because I usually try to avoid table names that _must_ be escaped (mixed caps, reserved words, etc). put assign_mapper() in place of

[sqlalchemy] Re: strange serial problem in postgres

2007-08-17 Thread Marco Mariani
Glauco ha scritto: Thank you kevin , i've worked a lot over PG and this tecnique is consolidated in our model.. but here the problem is that the column is a simplycolumn_name INTEGER NOT NULL references other_table(id) and i cannot understand why sqlalchemy whant to use it as a

[sqlalchemy] Re: sqlalchemy with turbogears and mapper-part2 connect and select

2007-08-17 Thread Marco Mariani
Lukasz Szybalski ha scritto: bind_meta_data() users_table = Table('users', metadata, autoload=True) class Users(object): pass usersmapper=mapper(Users,users_table) assign_mapper() in place of mapper() mysession=session.query(Users) 1. What would be the code from now on to

[sqlalchemy] Re: Hierachical data

2007-08-03 Thread Marco Mariani
Alexandre CONRAD ha scritto: Maybe this should need some attention to implement in SA some API to handle nodes (insert, move, remove) of herachical trees in SA the Nested Set way. There are several ways to implement schema and rules (and therefore APIs) just by looking at Celko's

[sqlalchemy] Re: SQLAlchemy 0.4 MERGED TO TRUNK

2007-07-31 Thread Marco Mariani
Michael Bayer ha scritto: can i have an example http://trac.turbogears.org/browser/branches/1.0/turbogears/database.py?rev=2320 281 [run_with_transaction.when(_use_sa())] 282 def sa_rwt(func, *args, **kw): 283 log.debug(New SA transaction) 284 transaction =

[sqlalchemy] Re: a renaming proposal

2007-07-27 Thread Marco Mariani
svilen ha scritto: Anyway it may depend which audience are u targeting with these names - those who never seen an API or those for which names are important only to associate them with a library/version/use-case... both extremes are equaly uninteresting imo. I think targeting those

[sqlalchemy] Re: autoload'ing metadata

2007-07-26 Thread Marco Mariani
[EMAIL PROTECTED] ha scritto: here some theory on comparing data trees, in order to produce the changeset edit scripts. http://www.pri.univie.ac.at/Publications/2005/Eder_DAWAK2005_A_Tree_Comparison_Approach_to_Detect.pdf The complete title of the paper is A Tree Comparison Approach To

[sqlalchemy] Re: Consistency with DB while modifying metadata

2007-07-25 Thread Marco Mariani
Anton V. Belyaev ha scritto: again, im not opposed to this feature and ill patch in an adequate (and fully unit-tested) implementation. but have you actually ever *had* this problem? or is it just hypothetical ? For example, a developer modifies the metadata and checks in. Another

[sqlalchemy] doing a one() on a unique key

2007-07-20 Thread Marco De Felice
Hi all for my first post I'm using the new one() method like this: query(Table).filter_by(and_(Table.c.field1 == val1, Table.c.field2 == val2)).one() filed1 + field2 has a unique constraint in Table, so there won't never be more than one row returned, but there may be none. When there's none I

[sqlalchemy] Re: Query.get with unordered multiple-column-primary-key

2007-06-13 Thread Marco Mariani
Roger Demetrescu ha scritto: query.get(dict(columnB='foo', columnA='bar') Lazy programmers are the best ones... :) That's the reason lazy programmers share a superclass for all their domain objects... hint, hint :-) --~--~-~--~~~---~--~~ You received

[sqlalchemy] Re: Generative style on SQL-API layer

2007-06-06 Thread Marco Mariani
svilen ha scritto: on a side note, here or for the query(), once i add .order_by() and similar, will be a possibility to remove/cancel them? e.g. .order_by(None) - similar to .join(None)? or should i keep a copy at the point before adding .order_by()? e.g. i want: q1 = query.filter(

[sqlalchemy] Re: Generative style on SQL-API layer

2007-06-06 Thread Marco Mariani
svilen ha scritto: because q1 with the order is _the_ query, made at point A somewhen, and stored there as a construct; much later at some point B i need to use that query but without the ordering - now i have to keep 2 copies of the query, w/ and w/out order. And this strip-the-ordering

[sqlalchemy] Re: In Turbogears, using the same transaction for mapped objects and direct operations

2007-06-06 Thread Marco Mariani
Sanjay ha scritto: BTW, the session transaction is stored in cherrypy.request.sa_transaction. Yes, but it's been added recently. Does this help simplify the statements? Transaction instances have a connection() property. So, cherrypy.request.sa_transaction.connection should work.

[sqlalchemy] Re: In Turbogears, using the same transaction for mapped objects and direct operations

2007-06-05 Thread Marco Mariani
Sanjay ha scritto: Need help on how to do it. Being a turbogears application where db entities like metadata and session are imported rather than created by me, I am confused and could not successfully implement the pattern provided in the docs. I'm sure there are cleaner ways, but this

[sqlalchemy] Re: winpdb and sqlalchemy

2007-05-16 Thread Marco Mariani
Edin Salkovic ha scritto: Currently, SQLAlchemy's setup(...) hasn't set this arg, meaning that setuptools uses its own algorithm to determine if SQLAlchemy can be installed as a zipped egg. You can switch off zip for all newly installed eggs, in ~/.pydistutils.cfg [easy_install] zip_ok

[sqlalchemy] Re: query().filter_by(boolean)

2007-04-13 Thread Marco Mariani
Michael Bayer wrote: please file a ticket for this. done, #535 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this

[sqlalchemy] query().filter_by(boolean)

2007-04-12 Thread Marco Mariani
I'm not trying the trunk, and it's the first time I use filter_by, but I guess: MappedClass.query().filter_by( MappedClass.column_name == 'Foo' ) equates to filter_by(False), because the .c is missing and it's comparing an UOWProperty to a string, instead of a Column object to a string

[sqlalchemy] parameter binding in connection.execute()

2007-04-03 Thread Marco Mariani
I know I can have bound parameters in engine.text(): t = engine.text(select foo from mytable where lala=:hoho) r = t.execute(hoho=7) ...but I need the same for connection.execute(), since I am using temporary tables and they are not accessible via engine.text Should I resort to manual

[sqlalchemy] Re: Dealing with uncommited data

2007-03-20 Thread Marco Mariani
Andreas Jung wrote: In a traditional application you can insert a new row and read the row within the same transaction. What is the typical usage pattern to deal with this in SA? In our particular setup (Zope) a new session is created for each new HTTP request and flushed automatically at

[sqlalchemy] Re: Help get Wikipedia entry through review

2007-02-15 Thread Marco Mariani
Paul Johnston wrote: Hi, Well, more than improving the quality of the article, we need to make a case for it being notable. The main criteria for this is: Software is notable if it has been the subject of multiple non-trivial published works whose source is independent of the software's

[sqlalchemy] Re: Object-oriented engine?

2007-02-09 Thread Marco Mariani
svilen wrote: how much OO u want? He's not using a DBMS. He has more OO-ness than SA could give him :-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

[sqlalchemy] just how lazy are backrefs?

2007-02-06 Thread Marco Mariani
I'm working inside TurboGears, autoload everything. Tested with 0.3.3 and Trunk. I find this strange behaviour: when I declare a relation between a Person and a Contract: assign_mapper(context, Contract, tbl['contracts'], properties = { 'responsible' : relation(Person,

[sqlalchemy] Re: just how lazy are backrefs?

2007-02-06 Thread Marco Mariani
Marco Mariani wrote: john.contracts_responsible gives me AttributeError: 'Person' object has no attribute 'contracts_responsabile' this is a cut-n-translate-n-paste typo, should read contracts_responsible of course --~--~-~--~~~---~--~~ You received

[sqlalchemy] Re: count(*) function

2007-01-15 Thread Marco Mariani
milena wrote: I have tried select([func.count(*)], from_obj=[table_name]).execute() but it didn't work I suppore you're not using mappers, so this is the fastest method: number_of_rows = table.count().execute().fetchone()[0] where table is the table object

[sqlalchemy] Re: Column aliases

2007-01-15 Thread Marco Mariani
Michael Bayer wrote: to have aliases of properties that are usable with get_by(), use the synonym function, described in: http://www.sqlalchemy.org/docs/adv_datamapping.myt#advdatamapping_properties_overriding Thank you. Altough the docs are very well done, there are many APIs and that

[sqlalchemy] Column aliases

2007-01-12 Thread Marco Mariani
Hi there This relates to Turbogears, but is really a SA question. I've customized TG authentication authorization to use my autloaded tables in Postgres and SqlAlchemy 0.3.3. In my schema, I have User.c.uid, the login name of the users, as a primary key TG uses a User mapper with two

[sqlalchemy] Re: unicode

2006-12-14 Thread Marco Mariani
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), Column('bar',

[sqlalchemy] autoload, composite foreign keys

2006-12-01 Thread Marco Mariani
Does sqlalchemy have some limit in handling composite primary keys with autoload? I've tried postgres 8.1 and SA 0.3 or trunk. I have a 'tree' of four tables, and SA does not create the full join to follow composite foreign keys. The schema and test model is in the attachment. As I've seen,