Re: [sqlalchemy] Connecting to AS400 with SQLAlchemy fails

2016-02-11 Thread Alex Hall
o other options at the moment and I need to get this working soon. On 2/11/16, Alex Hall <ah...@autodist.com> wrote: > I think I'm confused. Isn't Pyodbc an alternative to SQLAlchemy? If > not, how would the two work together? I just looked through the > 'Getting Started' and 'API' d

[sqlalchemy] Connecting to AS400 with SQLAlchemy fails

2016-02-10 Thread Alex Hall
Hello list, I sent this to the ibm_db list yesterday, but no one has responded yet. Since it's as much ibm_db as SA, I thought I'd try here as well in case any of you have used an AS400 before. I have ibm_db, ibm_db_sa, the latest sqlalchemy, and Python 2.7 (latest) installed. I can talk to SQLite

Re: [sqlalchemy] Recommended way to delete record given instance?

2016-02-08 Thread Alex Hall
" ? > > Best regards, > Thierry > > > 2016-02-06 5:16 GMT+01:00 Alex Hall <ah...@autodist.com>: > >> Hello all, >> Another basic question: given an instance of a record, can I somehow >> delete the record from a table? The longer story is this. >&g

[sqlalchemy] Using ibm_db to talk to AS400?

2016-02-08 Thread Alex Hall
Hi list, Thus far, I've been using very basic database actions on a local SQLite database as I've written the application. Now, though, I have my GUI able to drive all CRUD operations, and I'm nearing the time when I'll switch over to the actual system for which I've written the app: the company's

[sqlalchemy] Best practice for restricting input to columns?

2016-02-05 Thread Alex Hall
Hi all, What's the recommended way to restrict input? For instance, I store a phone number as an integer, and I need it to have 7, 10, or 11 digits. In its getter, I format it so it looks good as a string, and in its setter, I take the string the user inputs, strip only the integers, and store

[sqlalchemy] Recommended way to delete record given instance?

2016-02-05 Thread Alex Hall
day. Thanks! -- Alex Hall Automatic Distributors, IT Department ah...@autodist.com -- 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 sqlalchem

Re: [sqlalchemy] Modifying records across multiple modules?

2016-02-04 Thread Alex Hall
le, or as well as? Where are you getting the > object that you are putting in the first element of each of the > self.choices list? > > Simon > > On Thu, Feb 4, 2016 at 11:34 AM, Alex Hall <ah...@autodist.com> wrote: > >> It's all from a GUI, so it's something like th

Re: [sqlalchemy] Itterating over database row?

2016-02-04 Thread Alex Hall
4 Feb 2016, at 18:19, Alex Hall <ah...@autodist.com> wrote: >> >> Hello all, >> I'm setting my application up the way Simon suggested. I still use the >> table object so I can get its name for displaying in one list, but the >> other list (which holds the ac

Re: [sqlalchemy] Modifying records across multiple modules?

2016-02-04 Thread Alex Hall
sion.query(someTable) returns glorified tuples that can't be updated > session.query(someMappedClass) returns instances of someMappedClass, that > *can* be updated. > > Hope that makes sense, > > Simon > > On Thu, Feb 4, 2016 at 2:07 PM, Alex Hall <ah...@autodist.com>

Re: [sqlalchemy] Modifying records across multiple modules?

2016-02-04 Thread Alex Hall
(myEngine) #should create the empty tables, right? #main.py from DBDefinitions import * import DBInterface c1 = Customer(...) c2 = Customer(...) mt1 = MyOtherTable(...) if DBInterface.session.query(DBDefinitions.Customer).count == 0: DBInterface.session.add_all([c1, c2]) On 2/4/16, Alex Hall <

Re: [sqlalchemy] Modifying records across multiple modules?

2016-02-04 Thread Alex Hall
returns all mapped classes, something like this: > > def getAllClasses(): > return base.__subclasses__() > > (If your class hierarchy is more complicated you'd need a more > sophisticated function there) > > Simon > > On Thu, Feb 4, 2016 at 12:32 PM, Alex Hall

[sqlalchemy] Itterating over database row?

2016-02-04 Thread Alex Hall
Hello all, I'm setting my application up the way Simon suggested. I still use the table object so I can get its name for displaying in one list, but the other list (which holds the actual rows of the selected table) is using the relevant subclass of base. I use wx.ListCtrl to display everything,

[sqlalchemy] Re: history_meta.py: foreign keys in history table, and relationships

2015-10-13 Thread Alex Fraser
On Tuesday, 25 August 2015 11:23:51 UTC+10, Alex Fraser wrote: > > Is there a declarative way to add foreign keys to the history table when > using history_meta.py? In the app I'm making the user can view old versions > of a document, and I want to make sure e.g. the user that cre

Re: [sqlalchemy] history_meta.py: IndexError when creating a new object

2015-08-24 Thread Alex Fraser
) See here for unit tests for both of these issues. It uses an unmodified *history_meta.py*. https://github.com/z0u/satest/blob/master/test_versioned.py Cheers, Alex -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group

Re: [sqlalchemy] history_meta.py: IndexError when creating a new object

2015-08-24 Thread Alex Fraser
if the user saving an object is different from the user who last saved it. I also thought about adding an explicit *Versioned.create_version* method, but this suffices for now. Cheers, Alex -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe

[sqlalchemy] history_meta.py: foreign keys in history table, and relationships

2015-08-24 Thread Alex Fraser
is duplicated. E.g. instead of doing *user_name = v1.user.name*, I do: user = self.session.query(User).filter_by(id=v1.user_id).one() user_name = user.name I feel like I'm doing something wrong; any suggestions for improving this would be appreciated. Cheers, Alex SQLAlchemy 1.0.8, Python 3

[sqlalchemy] history_meta.py: IndexError when creating a new object

2015-08-23 Thread Alex Fraser
] obj_changed = True +else: +# The attribute has never had a value +attr[hist_col.key] = None if not obj_changed: # not changed, but we have relationships. OK Is this a reasonable thing to do? Cheers, Alex -- You received this message

[sqlalchemy] Trouble with AbstractConcreteBase and aliased columns

2015-07-09 Thread Alex Grönholm
The following script no longer works in 1.0.6, but does in 0.9.9: from sqlalchemy.ext.declarative import declarative_base, AbstractConcreteBase from sqlalchemy.ext.declarative.api import declared_attr from sqlalchemy.orm.mapper import configure_mappers from sqlalchemy.orm.session import Session

Re: [sqlalchemy] Trouble with AbstractConcreteBase and aliased columns

2015-07-09 Thread Alex Grönholm
:18 AM, Alex Grönholm wrote: The following script no longer works in 1.0.6, but does in 0.9.9: from sqlalchemy.ext.declarative import declarative_base, AbstractConcreteBasefrom sqlalchemy.ext.declarative.api import declared_attrfrom sqlalchemy.orm.mapper import configure_mappersfrom

Re: [sqlalchemy] contains_eager does not load relation data if related model appears twice in query

2015-05-25 Thread Alex S
Thank you very much for your work, Mike. -- 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

[sqlalchemy] contains_eager does not load relation data if related model appears twice in query

2015-05-23 Thread Alex S
Hi everyone! I've found that contains_eager() does not load relation objects from query in case when related model appears twice in query. The working code with example models and steps to reproduce is listed in the attached file, I'll briefly describe the issue here. There are four models:

[sqlalchemy] sqlacodegen 1.1.6 released.

2015-05-15 Thread Alex Grönholm
This update only fixes compatibility with SQLAlchemy 1.0. -- 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

Re: [sqlalchemy] Sending queue messages/emails after model commit

2014-09-23 Thread Alex Michael
Hey Jason, Thanks for your reply. That makes sense I guess. It just feels like this is something most webapps will need at some point and it's not as straightforward as someone would imagine. -- alex On Monday, September 22, 2014 6:22:14 PM UTC+2, jason kirtland wrote: Hi Alex, I have

[sqlalchemy] Sending queue messages/emails after model commit

2014-09-22 Thread Alex Michael
appreciate any help. Thanks! -- alex -- 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

Re: [sqlalchemy] More than one level of abstract base classes doesn't work

2014-09-05 Thread Alex Grönholm
Thanks. I've filed an issue https://bitbucket.org/zzzeek/sqlalchemy/issue/3185/more-than-one-level-of-abstract-concrete at Bitbucket. A follow-up question: Why are abstract base classes not present in the declarative class registry? Or is there another way to get all the mapped classes

Re: [sqlalchemy] More than one level of abstract base classes doesn't work

2014-09-05 Thread Alex Grönholm
to get every class whether mapped or not, maybe use Base.__subclasses__() ? What’s the use case where you need the abstract base in the decl class registry? it’s not really something you’d want to refer to in a relationship(). On Sep 5, 2014, at 9:56 AM, Alex Grönholm alex.g...@nextday.fi

Re: [sqlalchemy] More than one level of abstract base classes doesn't work

2014-09-05 Thread Alex Grönholm
, type)] perjantai, 5. syyskuuta 2014 17.19.21 UTC+3 Alex Grönholm kirjoitti: You're right, I'm dumb. I should've just used __subclasses__ and be done with it. The use case is that I have a client-server app and I build a list of all classes for the client so the client knows which column

Re: [sqlalchemy] More than one level of abstract base classes doesn't work

2014-09-05 Thread Alex Grönholm
Sorry to be asking more questions, but the docs on inheritance don't get into much details on how the properties are supposed to work. The following code produces unexpected results: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import

[sqlalchemy] More than one level of abstract base classes doesn't work

2014-09-04 Thread Alex Grönholm
The following code fails with AttributeError: 'NoneType' object has no attribute 'concrete': from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import AbstractConcreteBase, declarative_base Base = declarative_base() class Document(Base,

Re: [sqlalchemy] Encapsulating insert/update logic of mapped classes in the class itself

2014-06-02 Thread Alex Grönholm
:47 AM, Alex Grönholm alex.g...@nextday.fi javascript: wrote: This has been a problem for me for years. class DeliveryAddress(Base, Address): ... delivery_method = Column(String) ... @event.listens_for(DeliveryAddress, 'before_insert') def

Re: [sqlalchemy] Encapsulating insert/update logic of mapped classes in the class itself

2014-06-02 Thread Alex Grönholm
to remain agnostic of, but it provides for you all the components you need to create whatever system of hooks you'd like. On Jun 2, 2014, at 8:04 AM, Alex Grönholm alex.gronh...@nextday.fi mailto:alex.gronh...@nextday.fi wrote: That's the first thing I tried, but validators don't get

[sqlalchemy] Encapsulating insert/update logic of mapped classes in the class itself

2014-06-01 Thread Alex Grönholm
This has been a problem for me for years. class DeliveryAddress(Base, Address): ... delivery_method = Column(String) ... @event.listens_for(DeliveryAddress, 'before_insert') def before_insert_deliveryaddress(mapper, connection, target): settings =

[sqlalchemy] Mutable ARRAY

2014-05-03 Thread Alex Grönholm
There doesn't seem to be a class like MutableDict that provides equivalent functionality for the ARRAY column type. Any particular reason why? I'd like to be able to do .append() and .remove() on an array column. Do I have to roll my own? -- You received this message because you are

Re: [sqlalchemy] Mutable ARRAY

2014-05-03 Thread Alex Grönholm
03.05.2014 16:04, Michael Bayer kirjoitti: I'd like to provide mutablearray though, so if someone can roll it with some tests it can go right in. I'll look into it. Sent from my iPhone On May 3, 2014, at 9:02 AM, Alex Grönholm alex.gronh...@nextday.fi mailto:alex.gronh...@nextday.fi wrote

Re: [sqlalchemy] Re: Bitwise Flag Type

2014-04-01 Thread Alex
to change this. I've tried to use coerce_compared_value with no effect. Alex On Mon, Mar 31, 2014 at 8:49 PM, Alex quixop...@googlemail.com wrote: The hybrid property and custom comparator approach works like a charm, I had an inkling that hybrid propertyies were the correct approach but hadn't

Re: [sqlalchemy] Bitwise Flag Type

2014-04-01 Thread Alex
(TestModel.flag_one) And the negation of it: session.query(TestModel).filter(not_(TestModel.flag_one)) I can't figure out how to emit the required SQL on comparison with a boolean value though. Alex On Tue, Apr 1, 2014 at 1:54 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Apr 1, 2014, at 6

[sqlalchemy] Bitwise Flag Type

2014-03-31 Thread Alex Good
this in process_bind_param but then obviously there is no current value of the flag integer for me to operate against. So, I'm a bit lost, any ideas on how to implement this would be greatly appreciated. Thanks Alex -- You received this message because you are subscribed to the Google Groups

Re: [sqlalchemy] Re: Bitwise Flag Type

2014-03-31 Thread Alex
The hybrid property and custom comparator approach works like a charm, I had an inkling that hybrid propertyies were the correct approach but hadn't really thought about subclassing hybrid_property, this has helped me understand the custom types architecture a lot, thank very much. Alex On Mon

[sqlalchemy] HSTORE intermittent bug

2014-02-19 Thread alex
Hi there, I've been hitting an intermittent bug with SQLAlchemy/PostgreSQL using an HSTORE column. Some times, when I restart my process (pyramid over gevent over chaussette), I get a spew of such errors... some other time, everything goes just fine. It seems this bug hasn't been documented

[sqlalchemy] Build Query Without Objects

2014-01-14 Thread Alex Meadows
Greetings, I've been reading through the docs and am still very new to SQLAlchemy but haven't found an answer to my question. I am trying to write a query with SQLAlchemy but don't want to build any objects if it can be helped. Is this possible? I've read about reflection, but I'm still not

[sqlalchemy] sqlacodegen 1.1.4 released.

2014-01-02 Thread Alex Grönholm
This release fixes compatibility with the just released SQLAlchemy 0.9.0 final. -- 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

Re: [sqlalchemy] How can I use the OVERLAPS operator?

2013-12-18 Thread Alex Grönholm
Ah, I was completely unaware of tuple_(). That's what I was looking for. Thanks! keskiviikko, 18. joulukuuta 2013 18.31.42 UTC+2 Michael Bayer kirjoitti: On Dec 17, 2013, at 8:39 PM, Alex Grönholm alex.g...@nextday.fijavascript: wrote: I would like to check if two date ranges overlap

[sqlalchemy] How can I use the OVERLAPS operator?

2013-12-17 Thread Alex Grönholm
I would like to check if two date ranges overlap. This is done using the OVERLAPS operator http://www.postgresql.org/docs/9.2/static/functions-datetime.html . For example: SELECT (DATE '2001-02-16', DATE '2001-12-21') OVERLAPS (DATE '2001-10-30', DATE '2002-10-30'); How do I do this in

[sqlalchemy] sqlacodegen 1.1.3 released.

2013-12-11 Thread Alex Grönholm
This release fixes compatibility with SQLAlchemy 0.8.3 and onwards. The test suite passes on SQLAlchemy 0.9.0b1 as well. -- 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

Re: [sqlalchemy] Unit testing, mocking and dependency injection with SA Declarative.

2013-09-11 Thread Alex Grönholm
I wrote a blog post on this very topic recently: http://alextechrants.blogspot.fi/2013/08/unit-testing-sqlalchemy-apps.html tiistai, 10. syyskuuta 2013 19.43.35 UTC+3 Toph Burns kirjoitti: Could you use an in-memory, sqlite db for your testing? For our applications, we have an

[sqlalchemy] How do I unregister event listeners?

2013-09-11 Thread Alex Grönholm
I'm trying to test code that listens to session events on all sessions. I can't pin it on any particular session or even sessionmaker due to the architecture of the software (sessions are explicitly instantiated on the fly). All is well except that the listener sticks after the test is done,

[sqlalchemy] Re: How do I unregister event listeners?

2013-09-11 Thread Alex Grönholm
There seems to be an undocumented function named remove() in the sqlalchemy.event module that looks like what I want, but it doesn't work: Traceback (most recent call last): File /home/alex/virtualenv/triancore/lib/python3.3/site-packages/nose/case.py, line 198, in runTest self.test

Re: [sqlalchemy] How do I unregister event listeners?

2013-09-11 Thread Alex Grönholm
) On Sep 11, 2013, at 1:44 PM, Alex Grönholm alex.g...@nextday.fijavascript: wrote: Thanks for the quick reply. I don't want to use prerelease versions of SQLAlchemy though. Is there any recommended way of doing this in 0.8.2? keskiviikko, 11. syyskuuta 2013 20.40.40 UTC+3 Michael Bayer

[sqlalchemy] sqlacodegen 1.1.2 released

2013-09-01 Thread Alex Grönholm
This is another bugfix release. All reported issues have now been resolved. Changes in this version: - Fixed non-default schema name not being present in __table_args__ (fixes #2) - Fixed self referential foreign key causing column type to not be rendered - Fixed missing

[sqlalchemy] image field in mssql

2013-06-12 Thread alex bodnaru
(img) values(:img) DBSession.execute(sql, dict(img=bytearray(data)) data is not empty, but it just retrieves as bytearray(b'') could you advice me? many thanks in advance, alex -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from

Re: [sqlalchemy] image field in mssql

2013-06-12 Thread alex bodnaru
) buffer = image.getvalue() param = dict(picture=bytearray(buffer) thanks a lot for your consideration :) alex there was no need to use pyodbc.Binary, since it has the very same effect. On 06/12/2013 06:36 PM, Michael Bayer wrote: blobs are problematic, and this is often highly dependent on DBAPI

[sqlalchemy] sqlacodegen 1.1.1 released

2013-06-12 Thread Alex Grönholm
This is a bugfix release. Issues resolved: - Fixed TypeError when inflect could not determine the singular name of a table for a many-to-1 relationship - Fixed _IntegerType, _StringType etc. being rendered instead of proper types on MySQL -- You received this message because

[sqlalchemy] sqlacodegen 1.1.0 released

2013-05-25 Thread Alex Grönholm
Although it's only been a week since the initial release, I've already added a bunch of new features. Release highlights: - Added automatic detection of joined-table inheritance - Fixed missing class name prefix in primary/secondary joins in relationships - Instead of wildcard

[sqlalchemy] What is polymorphic_on needed for in a joined table inheritance schema?

2013-05-24 Thread Alex Grönholm
I used joined table inheritance in Hibernate and it worked fine without any extra discriminator columns. Why is it necessary in SQLAlchemy? I can understand the need for such a column in single table inheritance, but not joined table. -- You received this message because you are subscribed to

Re: [sqlalchemy] Announcing new model code generation tool: sqlacodegen

2013-05-18 Thread Alex Grönholm
18.05.2013 12:35, Chris Withers kirjoitti: On 18/05/2013 01:28, Alex Grönholm wrote: This is a tool that reads the structure of an existing database and generates the appropriate SQLAlchemy model code, using the declarative style if possible. Playing devils advocate to get my head around

[sqlalchemy] Announcing new model code generation tool: sqlacodegen

2013-05-17 Thread Alex Grönholm
After a while of trying to fix sqlautocode, I ended up writing a new tool instead. Copypasta from the README: - This is a tool that reads the structure of an existing database and generates the appropriate SQLAlchemy model code, using the declarative

[sqlalchemy] Re: Announcing new model code generation tool: sqlacodegen

2013-05-17 Thread Alex Grönholm
Forgot to add the link: https://pypi.python.org/pypi/sqlacodegen -- 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

[sqlalchemy] Enum recipe on SQLAlchemy 0.8.0 final

2013-04-10 Thread Alex Grönholm
The following class works on 0.8.0b2 but not 0.8.0 final: class EnumWrapper(SchemaType, TypeDecorator): def __init__(self, cls): kwargs = {'name': cls.__name__.lower()} self.impl = Enum(*(obj.key for obj in cls.values), **kwargs) self.wrapped = cls def

Re: [sqlalchemy] Enum recipe on SQLAlchemy 0.8.0 final

2013-04-10 Thread Alex Grönholm
10.04.2013 18:06, Michael Bayer kirjoitti: On Apr 10, 2013, at 5:10 AM, Alex Grönholm alex.gronh...@nextday.fi mailto:alex.gronh...@nextday.fi wrote: The following class works on 0.8.0b2 but not 0.8.0 final: class EnumWrapper(SchemaType, TypeDecorator): def __init__(self, cls

[sqlalchemy] statement preparation in sa

2013-01-13 Thread alex bodnaru
to executescript. is there any proved way to go? any special paramstyle? thanks in advance, alex -- 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

[sqlalchemy] What is the best way to load _all_ related entities into the session (recursively) of a given entity?

2012-11-06 Thread alex
in the relations takes too long and needs alot of memory. Is there an option to do that implicitly on a loaded entity, because I do not want to invoke each single relation to load it explicitly? Cheers, Alex -- You received this message because you are subscribed to the Google Groups sqlalchemy

[sqlalchemy] How do I create a child class from a parent class in SQLAlchemy's Joined Table Inheritance?

2012-10-29 Thread Alex Chamberlain
) What am I doing wrong? Is there a way to create a User from a Person? Thanks in advance, Alex -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/yYDW-COkmvkJ

Re: [sqlalchemy] How do I create a child class from a parent class in SQLAlchemy's Joined Table Inheritance?

2012-10-29 Thread Alex Chamberlain
So, there's no way to upgrade a Person to a User within the normal ORM? Thanks, Alex On Oct 29, 2012 3:00 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Oct 29, 2012, at 5:06 AM, Alex Chamberlain wrote: I posted this on StackOverflow (http://stackoverflow.com/q/13109085/961353

Re: [sqlalchemy] How do I create a child class from a parent class in SQLAlchemy's Joined Table Inheritance?

2012-10-29 Thread Alex Chamberlain
. Alex On Monday, October 29, 2012 3:47:51 PM UTC, Michael Bayer wrote: there's an old ticket proposing to add the feature of changing the class of an item but it has many tricky turns and corners and hasn't been worth the large amount of effort it would take to make it work perfectly in all

[sqlalchemy] Automatically Adding Casting to 'CASE' Expressions in Dialects

2012-09-28 Thread Alex D.
Is there a good way to have a dialect automatically add casting to 'THEN' expressions in 'CASE' statements? I'm working on a dialect for the H2 database, via Jython. H2 requires values in a 'THEN' expression to have explicit casts (see: Unknown data type thrown with a case statement where all

Re: [sqlalchemy] Automatically Adding Casting to 'CASE' Expressions in Dialects

2012-09-28 Thread Alex D.
Roger that, thanks for the prompt response. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/XU4Zfrz8KJQJ. To post to this group, send email to

Re: [sqlalchemy] making bindparms required by default

2012-08-28 Thread alex bodnaru
to the Text() pre-established, with the required=True flag turned on. thought of it too, but it won't do the work: i needed to catch :variables missing in the given bindparm. thanks a lot, alex On Aug 27, 2012, at 12:06 PM, alex bodnaru wrote: hello friends, for a migrated

Re: [sqlalchemy] making bindparms required by default

2012-08-28 Thread alex bodnaru
PM, alex bodnaru wrote: hello friends, for a migrated system, i'm using textual queries in the form: dbsession.execute(select name from table where id=:id, dict(id=1)) to my surprise, select ... id=:idd would still work, asuming idd is null, despite 'idd' is not in bindparms

[sqlalchemy] making bindparms required by default

2012-08-27 Thread alex bodnaru
in _TextClause __init__() would indeed make the 'idd' column required, thus raise an exception when not found in bind dict(id=1). is there an official way to acomplish this, or should i just hack in hardcoded? thanks in advance, alex -- You received this message because you are subscribed

Re: [sqlalchemy] dialect sensible declaration

2012-07-16 Thread alex bodnaru
='Deutsch') session.add(de) data = PageData(lang_code='de', data=uVielen Dank im Voraus) #this works data = PageData(lang=de, data=uVielen Dank im Voraus) #this fails session.add(data) session.flush() thanks in advance, alex On 07/15/2012 07:08 PM, Michael Bayer wrote: On Jul 15, 2012, at 5:53 AM

Re: [sqlalchemy] dialect sensible declaration

2012-07-16 Thread alex bodnaru
thank you very much michael. both ways worked like a charm. i have implemented the other way, though this is better and more general: any constraint with onupdate or ondelete attributes should have these attributes set to none if the dialect name is mssql. thanks a lot, alex On 07/16/2012 05

Re: [sqlalchemy] dialect sensible declaration

2012-07-15 Thread alex bodnaru
hello michael, friends, On 07/11/2012 10:31 AM, alex bodnaru wrote: hello michael, now it works. i also had to add uselist=False. i tried it the longest way possible, by adding a Pool first_connect listener, but this was not really needed. just the uselist. thanks a lot, alex

Re: [sqlalchemy] dialect sensible declaration

2012-07-11 Thread alex bodnaru
hello michael, now it works. i also had to add uselist=False. i tried it the longest way possible, by adding a Pool first_connect listener, but this was not really needed. just the uselist. thanks a lot, alex On 07/09/2012 04:25 PM, Michael Bayer wrote: On Jul 9, 2012, at 4:48 AM, alex

Re: [sqlalchemy] dialect sensible declaration

2012-07-09 Thread alex bodnaru
) #this relationship won't work, since at the moment the class is being made, the foreign key is not there yet. the foreign_keys=Lang.lang_code arg does calm the exception, but doesn't do the work. could i add the relationship to the mapper on the same event? thank in advance, alex On 07/07/2012 05:13 PM

Re: [sqlalchemy] dialect sensible declaration

2012-07-08 Thread alex bodnaru
it worked very well, thanks a lot michael :), alex On 07/07/2012 05:13 PM, Michael Bayer wrote: sure engine and connection have .dialect.name. Foreign key constraints don't matter on SQLite unless you've actually enabled them, which is rare. I'd still use an event though so at least

Re: [sqlalchemy] dialect sensible declaration

2012-07-07 Thread alex bodnaru
thanks a lot michael. i think i'll go this way :) best regards, alex On 07/07/2012 05:13 PM, Michael Bayer wrote: sure engine and connection have .dialect.name. Foreign key constraints don't matter on SQLite unless you've actually enabled them, which is rare. I'd still use an event

[sqlalchemy] dialect sensible declaration

2012-07-06 Thread alex bodnaru
hello friends, i need to define a foreign key differently for different dialects: ondelete='restrict' for most engines, but nothing (implied and not recognized) for mssql. could you help? thanks in advance, alex -- You received this message because you are subscribed to the Google Groups

Re: [sqlalchemy] dialect sensible declaration

2012-07-06 Thread alex bodnaru
(.) if get_dialect() != 'mssql': fk_parms.update(onupdate='restrict') fk = ForeignKey(**fk_parms) would the dialect be accessible from the engine, metadata etc? thanks in advance, alex On 07/06/2012 11:39 PM, Michael Bayer wrote: you'd use ForeignKeyConstraint along with the AddConstraint directive

Re: [sqlalchemy] CircularDependencyError with relationships

2012-06-06 Thread Alex Grönholm
06.06.2012 18:06, Michael Bayer kirjoitti: you need to use the post_update option described at http://docs.sqlalchemy.org/en/rel_0_7/orm/relationships.html#rows-that-point-to-themselves-mutually-dependent-rows . Thanks for the pointer. Problem solved :) On Jun 6, 2012, at 1:15 AM, Alex

[sqlalchemy] CircularDependencyError with relationships

2012-06-05 Thread Alex Grönholm
I have trouble configuring two relationships from one class to another. The following code should be fairly self-explanatory: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class Company(Base):

[sqlalchemy] Bug in joinedload('*') ?!

2012-05-08 Thread alex
the movies, which does not happen. When you set Entity as the baseclass of Movie and Director it works. Is this a bug or is there a reason I don't see? Thx in advance, alex -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send

[sqlalchemy] Re: Bug in joinedload('*') ?!

2012-05-08 Thread alex
praise for your work on sqlalchemy :D alex -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/_RONPI3aMWwJ. To post to this group, send email to sqlalchemy

Re: [sqlalchemy] Turning a Query instance into SQL (with parameters), need help w/ LIMIT/OFFSET in 0.7.x

2012-03-09 Thread Alex K
We use this recipe and in 0.7.5 it works ok with limit and offset. http://www.sqlalchemy.org/trac/wiki/UsageRecipes/old/DebugInlineParams On Fri, Mar 9, 2012 at 10:32 AM, Randy Syring rsyr...@gmail.com wrote: I found a recipe on stackoverflow for turning a query instance into a string,

Re: [sqlalchemy] Re: Unpickling of model instances fails when using mapped collections

2012-02-16 Thread Alex Grönholm
Yup, this is exactly what I did just 2 minutes ago :) -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/Eto2-sirT7wJ. To post to this group, send email to

Re: [sqlalchemy] duplicate key trick

2012-01-22 Thread Alex K
Thanks! Great work! :) On Sat, Jan 21, 2012 at 3:18 AM, Conor conor.edward.da...@gmail.com wrote: def get_constraint_name(e): # Unique constraint violations in PostgreSQL have error code 23505. if e.orig.pgcode == 23505: return re.search(r'^ERROR: duplicate key value violates

[sqlalchemy] a list as a named argument for an in clause

2012-01-22 Thread alex bodnaru
hello friends, i'm using sa at a quite low level, with session.execute(text, dict) is it possible to do something in the spirit of: session.execute(select * from tablename where id in (:ids), dict(ids=[1,2,3,4])) ? thanks in advance, alex -- You received this message because you

[sqlalchemy] override char() handling

2011-12-24 Thread alex bodnaru
hello friends, i'm happily using sqlalchemy in a tg 2.1 project. with a legacy database, thus my queries are in the form of dbsession.execute(sql). where should i hook a strip of the data from a char(len) field? this is needed for this application only. best regards and merry christmas, alex

Re: [sqlalchemy] empty query

2011-12-11 Thread Alex K
I need EmptyQuery because query that returns from my function used for different cases, and if I return [], it will raise error, because [] not has query methods like order_by. e.g. query1 = getComments(user_id).order_by('comment.time_create desc') query2 = getComments(user_id).order_by('id')

[sqlalchemy] union and literal_column

2011-12-09 Thread Alex Parij
Hi , I'm using SA 0.5. query1 = session.query(literal_column('Phrase').label('type')).filter(...) query2 = session.query(literal_column('Exact').label('type')).filter(...) and then : query1.union(query2) gives me : SELECT* 'Phrase' as type* FROM (SELECT 'Phrase' as type FROM table1 WHERE

[sqlalchemy] Persisting an object with cascading relationships

2011-11-18 Thread Alex Grönholm
My use case is the following: each SalesItem requires a calcPriceList and a salesPriceList (of type PriceList) attached to it. For that, SalesItem has two fields: calcpricelist_id = Column(BigInteger, ForeignKey(PriceList.id), nullable=False) salespricelist_id = Column(BigInteger,

Re: [sqlalchemy] Persisting an object with cascading relationships

2011-11-18 Thread Alex Grönholm
How silly of me not to have checked that in the docs. Rather embarrassing really :) Thanks. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/rTk1ea1hvrgJ. To

Re: [sqlalchemy] Single table inheritance + join weirdness

2011-11-16 Thread Alex Grönholm
Yeah my bad, the original query does indeed query for (Z.id, B.name). I had just changed it to A.name to get the printout for the workaround query and forgot to change it back before pasting here. If there's something I can do to contribute (not sure I'm qualified to write those tests), do

[sqlalchemy] Single table inheritance + join weirdness

2011-11-15 Thread Alex Grönholm
I encountered a little strangeness when joining to a class using single table inheritance. I was wondering why I got no results for one particular query. This was originally encountered with PostgreSQL but was successfully reproduced with SQLite. Is this a bug or a user error?

Re: [sqlalchemy] default NULL

2011-11-11 Thread Alex K
Thanks, but if I need allow nullable primary_keys it not works. I tried: user_id = db.Column(db.Integer, db.ForeignKey('user.id', ondelete='SET NULL'), primary_key=True, nullable=True, server_default=text('NULL')) it generates CREATE TABLE user_ip ( user_id INTEGER DEFAULT NULL, PRIMARY KEY

Re: [sqlalchemy] default NULL

2011-11-11 Thread Alex K
=' 127.0.0.1/32') and it raise error: ArgumentError: Mapper Mapper|UserIp|user_ip could not assemble any primary key columns for mapped table 'user_ip' Thanks! On Fri, Nov 11, 2011 at 2:35 PM, Wichert Akkerman wich...@wiggy.net wrote: On 11/11/2011 11:20 AM, Alex K wrote: Thanks, but if I

Re: [sqlalchemy] Re: sqlalchemy from_statement dynamic attributes for python objects instances

2011-10-21 Thread Alex K
try doing: level in row instead of recompiling the query with __str__() each time, very expensive, also not very accurate Thanks! -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

Re: [sqlalchemy] how to compile statement from string and params dict?

2011-10-21 Thread Alex K
Maybe compiler from sqlalchemy can help me? from sqlalchemy.sql import compiler from sqlalchemy.sql.expression import text t = text(st) c = compiler.SQLCompiler(db.engine.dialect, t) and now I don't know how pass the params dict to compiler. Thanks. On Fri, Oct 21, 2011 at 6:40 PM, Michael

Re: [sqlalchemy] Re: sqlalchemy from_statement dynamic attributes for python objects instances

2011-10-20 Thread Alex K
On Wed, Oct 19, 2011 at 7:57 PM, Michael Bayer mike...@zzzcomputing.comwrote: but I can't add options contains_eager like result = result.options(contains_eager(Comment.user)) Well no because you're digging way into RECURSIVE queries which SQLA doesn't yet support very nicely. Mapping

Re: [sqlalchemy] Re: sqlalchemy from_statement dynamic attributes for python objects instances

2011-10-20 Thread Alex K
: On Oct 20, 2011, at 4:03 AM, Alex K wrote: result2 = db.session.query(non_primary_mapper).from_statement('SELECT test.id AS test_id, test.user_id AS test_user_id, test.reply_id AS test_reply_id, test.text AS test_text FROM test LEFT OUTER JOIN user ON user.id = test.user_id LIMIT 1 OFFSET 0

Re: [sqlalchemy] Re: sqlalchemy from_statement dynamic attributes for python objects instances

2011-10-20 Thread Alex K
', content_comments_level_add) and it works. Thanks! On Thu, Oct 20, 2011 at 6:54 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Oct 20, 2011, at 10:45 AM, Alex K wrote: I solve this problem with new custom Query class: it appears all you're doing is injecting an extra column

<    1   2   3   4   >