[sqlalchemy] How to set Row instance attribute

2023-05-06 Thread sector119
Hello, I get some data from DB and have a sequence of Row objects, how it is possible to modify data in those objects attrs? Something like result = await dbsession.execute(query) services = result.all() for i, service in enumerate(services): services[i].title = f"some text here

Re: [sqlalchemy] "flatten" model columns in Row

2022-11-20 Thread sector119
Thank you, Mike! воскресенье, 20 ноября 2022 г. в 16:31:09 UTC+2, Mike Bayer: > the quickest way at the moment is to use select(X.__table__, y_col), or, > if you use select(X), you can execute from session.connection().execute(). > > > > On Sat, Nov 19, 2022, at 5:31 P

[sqlalchemy] "flatten" model columns in Row

2022-11-19 Thread sector119
Hello For example I have two models X and Y, I want to get all columns from X model and only one or two cols from Y model in the same Row as [(x_col1, x_col2, x_col3, y_col1), ...] but not [(X, y_col1)] as I get when I perform select(X, Y.col1).join(X.y) I just don't want to write all X model

Re: [sqlalchemy] SQLAlchemy 2. psycopg3 type adapt

2022-09-11 Thread sector119
022, at 4:15 PM, sector119 wrote: > > Hello, > > I got exception when I try to insert numpy.int8 type data. > sqlalchemy.exc.ProgrammingError: (psycopg.ProgrammingError) cannot adapt > type 'int8' using placeholder '%s' (format: AUTO) > > I'm trying to adapt it with co

[sqlalchemy] SQLAlchemy 2. psycopg3 type adapt

2022-09-10 Thread sector119
Hello, I got exception when I try to insert numpy.int8 type data. sqlalchemy.exc.ProgrammingError: (psycopg.ProgrammingError) cannot adapt type 'int8' using placeholder '%s' (format: AUTO) I'm trying to adapt it with code below, but it looks like a bit comprehensive. Maybe you can suggest

Re: [sqlalchemy] async mode and relationship more than one level deep

2021-07-22 Thread sector119
ship-loading-with-loader-options > > > > On Wed, Jul 21, 2021, at 4:25 PM, sector119 wrote: > > Hello, Mike > > When I want to use some relationship I just set selectinload option on it > like > > s = select(Database).options(selectinload(Database.person)) > > Here

[sqlalchemy] Re: async mode and relationship more than one level deep

2021-07-21 Thread sector119
s = select( Database ).options( selectinload( Database.person ).options( joinedload(Person.city) ) ) среда, 21 июля 2021 г. в 23:25:05 UTC+3, sector119: > Hello, Mike > > When I want to use some relationship I just set selectinload option on it > like > > s

[sqlalchemy] async mode and relationship more than one level deep

2021-07-21 Thread sector119
Hello, Mike When I want to use some relationship I just set selectinload option on it like s = select(Database).options(selectinload(Database.person)) Here Database.person is relationship with Person model But what to do if I want to access some relationship of Person model? For example

[sqlalchemy] No NOWAIT for FOR UPDATE

2021-06-13 Thread sector119
Hello! On a PostgreSQL database can't get NOWAIT with FOR UPDATE clause ( sqlalchemy 1.4.18 from sqlalchemy.future import select from unity.models.unity import Internal sql = select( Internal.person_id_internal ).with_for_update(nowait=True) str(sql) Out[12]: 'SELECT

[sqlalchemy] Set PostgreSQL default index tablespace

2021-01-24 Thread sector119
Hello Is it possible to set default tablespace for all indexes? I know that I cat set it with Index('my_index', my_table.c.data, postgresql_tablespace='my_tablespace') But I want to set set it by default somehow, that when I just put "index=True" on column, I get index created at some

Re: [sqlalchemy] Overlapping FK problem

2020-12-28 Thread sector119
one ? понедельник, 28 декабря 2020 г. в 19:53:24 UTC+2, Mike Bayer: > > > On Mon, Dec 28, 2020, at 12:37 PM, sector119 wrote: > > Thank You, Mike, > > Do you mean that I have to remove all foreign() annotations from all my > relationships like this? > servi

Re: [sqlalchemy] Overlapping FK problem

2020-12-28 Thread sector119
the foreign() annotation from the Transaction.service column. > the primary joins already have enough information based on the service_id, > organization_id and person_id columns. > > > On Mon, Dec 28, 2020, at 6:04 AM, sector119 wrote: > > I get following warning with my m

Re: [sqlalchemy] Overlapping FK problem

2020-12-28 Thread sector119
move the foreign() annotation from the Transaction.service column. > the primary joins already have enough information based on the service_id, > organization_id and person_id columns. > > > On Mon, Dec 28, 2020, at 6:04 AM, sector119 wrote: > > I get following warning with my mo

[sqlalchemy] Overlapping FK problem

2020-12-28 Thread sector119
I get following warning with my model: SAWarning: relationship 'Transaction.organization' will copy column organizations.schema to column transactions.schema, which conflicts with relationship(s): 'Transaction.service' (copies services.schema to transactions.schema). If this is not the

Re: [sqlalchemy] from_statement and cte problem

2019-07-01 Thread sector119
return get_locality_path_q(self.id) вторник, 2 июля 2019 г., 0:03:20 UTC+3 пользователь Mike Bayer написал: > > I don't know what you mean. is there SQL you know you want or is that the > part you want to figure out? > > > On Mon, Jul 1, 2019, at 4:21 PM, sector119 wrote: > > Mike,

Re: [sqlalchemy] from_statement and cte problem

2019-07-01 Thread sector119
Mike, is it possible to load "@property" as subquery? Maybe as ARRAY[path_item, path_item, ...] воскресенье, 30 июня 2019 г., 20:26:42 UTC+3 пользователь Mike Bayer написал: > > > > On Sun, Jun 30, 2019, at 5:37 AM, sector119 wrote: > > Nice, thanks a lot, Mi

Re: [sqlalchemy] from_statement and cte problem

2019-06-30 Thread sector119
(self.id) воскресенье, 30 июня 2019 г., 1:11:21 UTC+3 пользователь Mike Bayer написал: > > > > On Sat, Jun 29, 2019, at 11:24 AM, sector119 wrote: > > Hello, > > > I have Locality model with 'path' property to get path from 'root' of tree to > current item, everything

[sqlalchemy] from_statement and cte problem

2019-06-29 Thread sector119
Hello, I have Locality model with 'path' property to get path from 'root' of tree to current item, everything works ok, but I can't get result as Locality instance list.. When I use *'*object_session(self).query(Locality).from_statement(q).order_by(Locality.id)' I get

Re: [sqlalchemy] Alembic and postgresql multiple schema question

2018-09-01 Thread sector119
> if you want individual migration sections for each schema, with or > without "schema" written in, there's ways to do all that also but that > doesn't seem necessary if you are sharing a single model with multiple > identical schemas. > The problem is that some one might alter some tables

Re: [sqlalchemy] Alembic and postgresql multiple schema question

2018-08-31 Thread sector119
тверг, 30 августа 2018 г., 16:09:35 UTC+3 пользователь Mike Bayer написал: > > On Thu, Aug 30, 2018 at 7:11 AM, sector119 > wrote: > > Mike, but in run_migrations_online() I use conn = > > connection.execution_options(schema_translate_map={None: schema_name}) > >

Re: [sqlalchemy] Alembic and postgresql multiple schema question

2018-08-30 Thread sector119
:12 AM, sector119 > wrote: > > Hello > > > > I have N schemas with the same set of tables, 1 system schema with > users, > > groups, ... tables and 6 schemas with streets, organizations, > transactions, > > ... tables. > > On those schemas tables

[sqlalchemy] Re: Alembic and postgresql multiple schema question

2018-08-29 Thread sector119
rint("Migrating schema %s" % schema_name) context.configure( connection=conn, target_metadata=target_metadata ) with context.begin_transaction(): context.run_migrations() среда, 29 августа 2018 г., 12:12:

[sqlalchemy] Alembic and postgresql multiple schema question

2018-08-29 Thread sector119
Hello I have N schemas with the same set of tables, 1 system schema with users, groups, ... tables and 6 schemas with streets, organizations, transactions, ... tables. On those schemas tables I don't set __table_args__ = ({'schema': SCHEMA},) I just call dbsession.execute('SET search_path TO

Re: [sqlalchemy] Extra table name in FROM clause

2018-01-05 Thread sector119
Here is SQL that works as expected: SELECT m.*, d.* FROM ( SELECT person_id, service_id, person_id_internal, meters_readings, -- two-dimensional array meters_readings [generate_subscripts(meters_readings, 1)] [1] AS meter_id, meters_readings

[sqlalchemy] Re: Extra table name in FROM clause

2018-01-04 Thread sector119
oops, .filter(database.c.person_id == person_id) fixed the problem. Thanks! четверг, 4 января 2018 г., 23:08:35 UTC+2 пользователь sector119 написал: > > Hello, > > In this query I get extra (unexpected) "databases" table name in FROM > claus

[sqlalchemy] Extra table name in FROM clause

2018-01-04 Thread sector119
Hello, In this query I get extra (unexpected) "databases" table name in FROM clause q = dbsession.query( meter_readings.c.reading, database.c.service_id ). \ select_from( database.outerjoin(meter_readings, true()) ).filter(Database.person_id == person_id)

Re: [sqlalchemy] NotImplementedError: Operator 'getitem' is not supported on this expression

2018-01-04 Thread sector119
erce? четверг, 4 января 2018 г., 17:48:56 UTC+2 пользователь Mike Bayer написал: > > On Thu, Jan 4, 2018 at 6:49 AM, sector119 <sect...@gmail.com > > wrote: > > Hello, > > > > > > I try to rewrite "meters_readings[generate_subscrip

[sqlalchemy] NotImplementedError: Operator 'getitem' is not supported on this expression

2018-01-04 Thread sector119
eral() q = dbsession.query( meter_readings, database ). \ select_from(database). \ outerjoin(meter_readings, true()). \ filter(Database.person_id == person_id) return q File "/home/sector119/PycharmProjects/epsilon/epsilon

Re: [sqlalchemy] update instance.relation.attr in instance.attr "set event listener"

2016-03-23 Thread sector119
Going back to the subject )) I get error (and no data updated) while using no_autoflush /Users/sector119/PythonVirtualEnv/supplements/lib/python2.7/site-packages/sqlalchemy/orm/session.py:2122: SAWarning: Attribute history events accumulated on 1 previously clean instances within inner-flush

Re: [sqlalchemy] need help with query

2016-03-01 Thread sector119
With that query I get: InvalidRequestError: Could not find a FROM clause to join from. Tried joining to , but got: Can't find any foreign key relationships between 'category' and 'product'. Product and category model has many to many relationship -- You received this message because you are

[sqlalchemy] Re: Need help with update + select query

2016-02-25 Thread sector119
product_t = Product.__table__ product_flavor_t = ProductFlavor.__table__ product_t_a = product_t.alias() op.add_column(u'product', sa.Column('servings', sa.Integer(), nullable=True)) op.add_column(u'product', sa.Column('flavors_count', sa.Integer(), nullable=True)) servings =

[sqlalchemy] Re: Need help with update + select query

2016-02-25 Thread sector119
, 25 февраля 2016 г., 15:19:11 UTC+2 пользователь sector119 написал: > > Hello, > > Can some one help me with that query? I get AttributeError: servings > I expect that sqlalchemy use update from select for that query or it's not > possible and I must use select(...).as_scalar()

Re: [sqlalchemy] Need help with update + select query

2016-02-25 Thread sector119
s = select([func.coalesce(func.avg(product_flavor_t.c.size), 0).label('f1'), func.count(product_flavor_t.c.id).label('f2')]).\ select_from(product_t.outerjoin(product_flavor_t)) op.execute(product_t.update().values(servings=s.c.f1, flavors_count=s.c.f2)) I tried that, but it

Re: [sqlalchemy] update instance.relation.attr in instance.attr "set event listener"

2016-02-25 Thread sector119
.__table__.c.id) connection.execute( Product.__table__.update().where(Product.__table__.c.id == target.product_id).values(quantity=quantity)) четверг, 25 февраля 2016 г., 11:52:50 UTC+2 пользователь Simon King написал: > > On Wed, Feb 24, 2016 at 9:51 PM, sector119 <sect...@

[sqlalchemy] Need help with update + select query

2016-02-25 Thread sector119
Hello, Can some one help me with that query? I get AttributeError: servings I expect that sqlalchemy use update from select for that query or it's not possible and I must use select(...).as_scalar() for every updated column? s =

[sqlalchemy] update instance.relation.attr in instance.attr "set event listener"

2016-02-24 Thread sector119
Hello! I have two models, Product and ProductFlavor with one-to-many relationship And I have a listener, which I want to update Product.quantity on ProductFlavor.quantity change: @event.listens_for(ProductFlavor.quantity, 'set') def quantity_set(target, value, oldvalue, initiator): if value

[sqlalchemy] Re: How to jsonify Query result?

2015-07-15 Thread sector119
Ok, that approach isn't cool.. I get another one from flask_jsontools and it does what I need! json.dumps(q, cls=DynamicJSONEncoder) Base = declarative_base(cls=JsonSerializableBase) import decimal from datetime import datetime, date from json import JSONEncoder from sqlalchemy import

[sqlalchemy] Re: How to jsonify Query result?

2015-07-14 Thread sector119
recursion depth exceeded while calling a Python object What can I do with that? Help me please! Traceback (most recent call last): File s.py, line 10, in module print repr(r.to_dict()) File /Users/sector119/PycharmProjects/epsilon/epsilon/models/serializer.py, line 31, in to_dict value

[sqlalchemy] How to jsonify Query result?

2015-07-11 Thread sector119
Hello, How can we jsonify the tuples returned by Query ? Thanks. -- 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

[sqlalchemy] Re: Can't create table with ENUM type column

2015-07-05 Thread sector119
Column(ENUM('copy', 'insert', 'update', name='import_action')) *works* Column(ARRAY(ENUM('copy', 'insert', 'update', name='import_action'))) *doesn't create enum type * -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group

[sqlalchemy] Re: Can't create table with ENUM type column

2015-07-05 Thread sector119
Code below creates enum type, but server_default still doesn't work as I expect )) import_action = ENUM('copy', 'insert', 'update', name='import_action') class Import(Base): __tablename__ = 'import' id = Column(Integer, primary_key=True) name = Column(UnicodeText, nullable=False)

[sqlalchemy] Can't create table with ENUM type column

2015-07-05 Thread sector119
Hello, Help me create table with enum type column, SA do not create enum type before table :( And server_default doesn't set value that I expect, actions import_action[] DEFAULT ARRAY['copy'] NOT NULL it set array['copy'], not import_action['copy'] as default... Code and exception: from

Re: [sqlalchemy] Can't create table with ENUM type column

2015-07-05 Thread sector119
Thanks a lot for your help, Michael ! -- 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

[sqlalchemy] Can't create table in just created schema

2015-06-28 Thread sector119
Hello! I can't create table in just created schema without commit() after CreateSchema statement, code and traceback posted below. Is it Ok? Or I make something wrong? PS. Can I call CreateSchema with .execute_if(callable_=should_create) ? from sqlalchemy import create_engine from

Re: [sqlalchemy] How to create model with dynamically set schema?

2015-02-05 Thread sector119
Michael, I want to set search_path to locality schema that depends on user settings. And I have some kind of admin utility where user can setup locality environment (schema) with set of tables and I have the list of models those should be created at some schema that admin-user would specify..

[sqlalchemy] Can't access model object backref

2013-01-25 Thread sector119
Hello. I have Category model: class Category(Base): __tablename__ = 'categories' id = Column(Integer, primary_key=True) parent_id = Column(Integer, ForeignKey('categories.id')) name = Column(Unicode(255), nullable=False) description = Column(UnicodeText) position =

[sqlalchemy] Re: Can't access model object backref

2013-01-25 Thread sector119
I want to order_by(Category.parent.name, Category.name) is it possible? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to

[sqlalchemy] column_property and class Mixin problem

2012-01-03 Thread sector119
Hello. Can't get this to work, I want to get users who is online - users where last_read column = now() - 30 minutes With DBSession.query(User).filter(User.is_online) query But get the following error: File /home/eps/devel/tourclub/pbb/pbb/models/__init__.py, line 147, in module class

Re: [sqlalchemy] column_property and class Mixin problem

2012-01-03 Thread sector119
Now I get File /home/eps/devel/tourclub/sqlalchemy/lib/sqlalchemy/sql/visitors.py, line 59, in _compiler_dispatch return getter(visitor)(self, **kw) File /home/eps/devel/tourclub/sqlalchemy/lib/sqlalchemy/sql/compiler.py, line 370, in visit_column raise exc.CompileError(Cannot

[sqlalchemy] Re: column_property and class Mixin problem

2012-01-03 Thread sector119
Thanks a lot, Michael! Works like a charm! -- 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/-/W6s3M_bzrRAJ. To post to this group, send email to

[sqlalchemy] Re: can't get delete-orphan work

2011-11-13 Thread sector119
Thanks a lot, Michael! -- 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/-/Vc5LM46bOiUJ. To post to this group, send email to sqlalchemy@googlegroups.com. To

[sqlalchemy] can't get delete-orphan work

2011-11-12 Thread sector119
Hi. I think that I'm doing somethig wrong, but I can't get delete-orphah work... No DELETES on static_page_urls are performed... 2011-11-12 12:31:14 EET LOG: statement: BEGIN 2011-11-12 12:31:14 EET LOG: statement: DELETE FROM static_pages WHERE static_pages.id = 1 2011-11-12 12:31:14 EET

[sqlalchemy] Re: after_insert mapper event: can't populate target.BACKREF.attr

2011-11-09 Thread sector119
# test_event.py from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, ForeignKey from sqlalchemy import Integer, UnicodeText from sqlalchemy import event from sqlalchemy.orm import

[sqlalchemy] Re: to many statements for collection.append?

2011-11-09 Thread sector119
Thanks, Michael, it was my mistake. I use sqlalchemy with pyramid and comment = ReportComment(content=form.content.data, user=self.request.user) where self.request.user is class RequestFactory(Request): @reify def user(self): db = DBSession() username =

Re: [sqlalchemy] to many statements for collection.append?

2011-11-09 Thread sector119
report.id = 1 2011-11-09 13:30:24 EET LOG: statement: SELECT users.id AS users_id, users.username AS users_username FROM users WHERE users.username = 'sector119' 2011-11-09 13:30:24 EET LOG: statement: SELECT comment.id AS comment_id, comment.content AS comment_content

[sqlalchemy] after_insert mapper event: can't populate target.BACKREF.attr

2011-11-08 Thread sector119
Hello. Why comments_after_insert_listener return None for target.report - backref for TripReport.comments? class TripReportComment(Base): __tablename__ = 'trip_report_comments' id = Column(Integer, primary_key=True) content = Column(UnicodeText, nullable=False) report_id =

[sqlalchemy] to many statements for collection.append?

2011-11-08 Thread sector119
Hi. Why SA produce last UPDATE if I set report_id value? And why it produces those two SELECTs if I do not perform read access to report and report.comments? Should not it exec only one insert? report = session.query(TripReport).get(id) comment = TripReportComment(content=form.content.data,

[sqlalchemy] Re: how to replace selectable but not with original table alias?

2011-10-13 Thread sector119
a pattern like this.   Here it would likely mean varying between t1 and t2 before s is created. On Oct 12, 2011, at 8:32 AM, sector119 wrote: Hello. Is it possible to replace some table with defferent one? I want to get the same query, with the same columns, having, order_by

[sqlalchemy] how to replace selectable but not with original table alias?

2011-10-12 Thread sector119
Hello. Is it possible to replace some table with defferent one? I want to get the same query, with the same columns, having, order_by, where clauses but with different table name. s.replace_selectable(t1, t1_alias) - works s.replace_selectable(t1, t2) - doesn't Thanks. -- You received this

[sqlalchemy] why func.sum(some_table.c.bigintfield) returns Decimal ?

2011-09-26 Thread sector119
Hello. Why func.sum(some_table.c.bigintfield) returns Decimal ? documents_table.c.sum has BigInteger type (postgresql table field has bigint type) the same issue I got with postgresql date_part func, when I extract year or month I got Decimal result, not int s =

[sqlalchemy] how to make obj copy with all relations?

2011-07-01 Thread sector119
Hello. How to make a copy of object with all relations? But with new PK value and save? Thanks. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send

[sqlalchemy] Re: something wrong with relationship caching at _trunk_

2010-12-22 Thread sector119
(caching_query.FromCache('default', 'by_username')).\ filter_by(username=username).one() def print_groups(user): for g in user.groups: print g.name ### END HELPERS ### CREATE metadata.create_all(engine) ### END CREATE ### POPULATE u1 = User('sector119', u'A', u'B', u'C

[sqlalchemy] Re: something wrong with relationship caching at _trunk_

2010-12-22 Thread sector119
% python2.6 sacache.py 1. sector119 groups: G1 2. sector119 groups: G1 1. sector120 groups: G1 2. sector120 groups: G1 -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe

[sqlalchemy] Re: something wrong with relationship caching at _trunk_

2010-12-22 Thread sector119
sacache.py 1. sector119 groups: G1 2. sector119 groups: G1 1. sector120 groups: G2 2. sector120 groups: G2 Now I would try to move from 6944 to 7195 (current) changeset by changeset and see where it would be broken. -- You received this message because you are subscribed to the Google Groups

[sqlalchemy] Re: something wrong with relationship caching at _trunk_

2010-12-22 Thread sector119
Thank you, Michael! On 22 Грд, 18:38, Michael Bayer mike...@zzzcomputing.com wrote: Thank you, please apply the change in r9327b3748997 to your _params_from_query() function. On Dec 22, 2010, at 5:47 AM, sector119 wrote: from beaker import cache from sqlalchemy import * from

[sqlalchemy] something wrong with relationship caching at _trunk_

2010-12-21 Thread sector119
`username` param and access `groups` relationship I got the same groups as with first query and no sql being executed to get those groups... The same code works correctly with 0.6.5. To reproduce: % sudo invoke-rc.d memcached restart [sudo] password for sector119: Restarting memcached: memcached

[sqlalchemy] Re: something wrong with relationship caching at _trunk_

2010-12-21 Thread sector119
fragments like this.   Though your print_groups() function here is wrong: def print_groups(user):    for g in u.groups:        print g.name On Dec 21, 2010, at 9:15 AM, sector119 wrote: Hello! I have a problem with my relationship caching with 0.7b1 (current trunk) When I perform

[sqlalchemy] How to invalidate RelationshipCache?

2010-07-05 Thread sector119
Hi All! I have users_table mapped to User model. ### mapper( User, users_table, properties={ 'locality': relation(Locality, uselist=False), 'office': relation(Office, uselist=False, primaryjoin=users_table.c.office_id==offices_table.c.id,

[sqlalchemy] Re: How to invalidate RelationshipCache?

2010-07-05 Thread sector119
cache_user_relationships = cache.RelationshipCache('default', 'by_id', User.locality).and_(                            cache.RelationshipCache('default', 'by_id', User.office)).and_(                            cache.RelationshipCache('default', 'by_id', User.groups)).and_(                  

[sqlalchemy] Re: How to invalidate RelationshipCache?

2010-07-05 Thread sector119
Is it have sense to have something like RelationFromCache(region, namespace, attribute) ? To use it like: meta.Session.query(User).\ options(cache.RelationFromCache('default', 'by_id', User.office)).\ filter_by(username=username, disabled=False).\

[sqlalchemy] Re: How to invalidate RelationshipCache?

2010-07-05 Thread sector119
I was wrong. This works, but it's not handy to recreate query manually that was generated by by SA (it's lazy relation) :( Maybe it's possible to do that another way? q = meta.Session.query(Office).\ options(cache.FromCache('default', 'by_id')).\

[sqlalchemy] Re: How to invalidate RelationshipCache?

2010-07-05 Thread sector119
And one more question about caching, how can I invalidate all cached queries for User model? For one user I make: q = meta.Session.query(User).\ options(cache_user_relationships).\ options(cache.FromCache('default', 'by_username')).\

[sqlalchemy] need help with array of tuples and composite custom type in postgresql

2010-01-12 Thread sector119
Hi All. I have a problem with that query, how to rewrite it using sqlalchemy? What to do with tuples - array_agg(row(meter_id, organization_reading, reading)::meterreading) in psql I see it like {(499680,137,141),(500765,258,267)} ? And composite custom type - meterreading ? How to create that

[sqlalchemy] Re: Something wrong with pool. Got Connection is already closed None None with copy_from and big file.

2009-11-21 Thread sector119
On Nov 4, 7:13 pm, Michael Bayer mike...@zzzcomputing.com wrote: copy_from() probably creates some state that is not compatible with the connection being used afterwards for subsequent operations, or alternatively copy_from() is not compatible with some previous state.   The pool does

[sqlalchemy] ForeignKey and ForeignKeyConstraint copy() method make FK copy without arguments

2009-11-04 Thread sector119
Hi All ForeignKey and ForeignKeyConstraint copy() method make FK copy without arguments, for example deferrable, ... class ForeignKey: def copy(self, schema=None): Produce a copy of this ForeignKey object. return ForeignKey(self._get_colspec(schema=schema)) class

[sqlalchemy] Re: ForeignKey and ForeignKeyConstraint copy() method make FK copy without arguments

2009-11-04 Thread sector119
--- schema.py 2009-11-04 13:27:37.124466356 +0200 +++ schema.py 2009-11-04 13:27:21.486350738 +0200 @@ -909,7 +909,17 @@ def copy(self, schema=None): Produce a copy of this ForeignKey object. -return ForeignKey(self._get_colspec(schema=schema)) +return

[sqlalchemy] Re: not expected generated update query values

2009-11-04 Thread sector119
Oh, I forgot about that, it wasn't that behaviour that I realy axpect.. I modify sql/compiller.py a bit to show what I mean. If I specify some bindparam'eters at value(...) I want _only_ that columns to be at update SET or insert VALUES.. --- compiler.py.orig2009-11-02 18:00:17.548954070

[sqlalchemy] Re: ForeignKey and ForeignKeyConstraint copy() method make FK copy without arguments

2009-11-04 Thread sector119
done. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to

[sqlalchemy] Something wrong with pool. Got Connection is already closed None None with copy_from and big file.

2009-11-04 Thread sector119
I use sqlalchemy 0.6 and psycopg2 2.0.13. When I try to copy from some little file it's ok, when from some bigger one I got error and log posted below. When I use pgbouncer and pass poolclass=pool.NullPool to create_engine everything wor perfect with large file too. My query is:

[sqlalchemy] Re: can't import ARRAY from dialects.postgresql

2009-10-24 Thread sector119
The latest trunk. from sqlalchemy.dialects.postgresql import ARRAY Traceback (most recent call last): File console, line 1, in module ImportError: cannot import name ARRAY from sqlalchemy.dialects.postgresql.base import ARRAY from sqlalchemy.dialects import postgresql 'ARRAY' in

[sqlalchemy] UnicodeDecodeError with pg8000 postgresql.conf client_encoding=utf8, engine encoding=utf-8

2009-10-24 Thread sector119
Hi All. I've got UnicodeDecodeError: 'ascii' codec can't decode byte 0xa1 in position 3: ordinal not in range(128) Why it can happen? I use client_encoding=utf8 at postgresql.conf and encoding=utf-8 at create_engine. File 'string', line 2 in submit File '/home/sector119/devel/eps_env/lib

[sqlalchemy] Re: not expected generated update query values

2009-10-23 Thread sector119
Thanks a lot, Michael! On Oct 23, 4:09 am, Michael Bayer mike...@zzzcomputing.com wrote: On Oct 22, 2009, at 3:26 PM, sector119 wrote: Something strange, Michael.. All bindparams are different. Compliller should not add to SET all params if values() has bindparam args, no? where() have

[sqlalchemy] own compiler visit_update method

2009-10-23 Thread sector119
Hi! Is it possible to easily add tables to FROM clause, now I use following code to append additional table names but it look like a hack.. at PGCompiler.visit_update() I see self.stack.append({'from': set ([update_stmt.table])}) where and how it's used, may be using this I can append some

[sqlalchemy] can't import ARRAY from dialects.postgresql

2009-10-23 Thread sector119
Is there something wrong with ARRAY type in SA 0.6? no dialects/ dialect/__init__.py has ARRAY at __all__ !? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

[sqlalchemy] Re: can't import ARRAY from dialects.postgresql

2009-10-23 Thread sector119
It's on trunk. Elso can't import orm from sqlalchemy :/ On Oct 23, 6:00 pm, sector119 sector...@gmail.com wrote: Is there something wrong with ARRAY type in SA 0.6? no dialects/ dialect/__init__.py has ARRAY at __all__ !? --~--~-~--~~~---~--~~ You received

[sqlalchemy] not expected generated update query values

2009-10-22 Thread sector119
Hi All! Why I get at SET part not only items from values(...), but all from params passed to session.execute? transactions_update = model.transactions_table.update().where(and_(model.transactions_table.c.commit_date==bindparam('commit_date'),

[sqlalchemy] Re: not expected generated update query values

2009-10-22 Thread sector119
though likely cleaner to pass the exact set of parameters desired. How to pass that params if I use bindparam at where() and values(), but I don't want to update colums that are at where() clause, only at values() ? --~--~-~--~~~---~--~~ You received this message

[sqlalchemy] Re: not expected generated update query values

2009-10-22 Thread sector119
, Michael Bayer mike...@zzzcomputing.com wrote: sector119 wrote: though likely cleaner to pass the exact set of parameters desired. How to pass that params if I use bindparam at where() and values(), but I don't want to update colums that are at where() clause, only at values() ? if you

[sqlalchemy] unbound method execute() must be called with Session instance as first argument (got Select instance instead)

2009-08-11 Thread sector119
Hi all! Why I get unbound method execute() must be called with Session instance as first argument (got Select instance instead) with following code? from twisted.internet import reactor, task, threads from twisted.application import service from twisted.python import log from sqlalchemy import

[sqlalchemy] How to set default join onclause if table has more than one FK to another table?

2009-03-11 Thread sector119
Hi All! How to set default join condition if table has more than one FK to another table? It may be Transaction.user_id==User.id or Transaction.rollback_user_id==User.id, I want first one to be default, is it possible to do? transactions_table = sa.Table('transactions', meta.metadata,

[sqlalchemy] Re: miss for postgres_from in update() :(

2009-03-05 Thread sector119
I create a small (4 lines) patch for databases/postgres.py def _append_from(self, text, stmt): return text.replace(' WHERE', ' FROM ' + string.join([table.name for table in stmt.kwargs['postgres_from']], ', ') + ' WHERE') def visit_update(self, update_stmt): text = super(PGCompiler,

[sqlalchemy] miss for postgres_from in update() :(

2009-03-04 Thread sector119
Hi all! u = transactions_table.update().\ where(and_(transactions_table.c.commit_date==current_date, \ transactions_table.c.serial==serial, \ transactions_table.c.user_id==users_table.c.id, \ users_table.c.office_id==id)).\

[sqlalchemy] sequence with predicate, locks and select for update

2009-02-24 Thread sector119
Hi All! I use postgresql and I have to emulate partial sequence (sequence with predicate). I have transactions table with serial_id field - this field have to be autoincrement field and unique for commit_date and user_office_id. When I perform an insert to this table I have to do something

[sqlalchemy] Re: sequence with predicate, locks and select for update

2009-02-24 Thread sector119
In SQL I hate that second SELECT, I can't perform SELECT MAX (serial_id) FROM transactions WHERE bla,bla,bla FOR UPDATE; because I get ERROR: SELECT FOR UPDATE/SHARE is not allowed with aggregate functions... --~--~-~--~~~---~--~~ You received this message

[sqlalchemy] Re: does tometadata have to change foreign key schema name if it already specified?

2009-01-21 Thread sector119
)) return Table(table.name, metadata, schema=schema_map[table.schema], *args) usage: m2 = MetaData() t2 = copy_table(t, m2, {None:'SOME_SCHEMA', 'system':'system'}) will map tables with no schema to SOME_SCHEMA, tables with system to the system schema. On Jan 20, 2009, at 3:02 PM, sector119

[sqlalchemy] does tometadata have to change foreign key schema name if it already specified?

2009-01-20 Thread sector119
Hi ALL! Does tometadata have to change foreign key schema name if it already specified? For example if I have column 'user_id' with 'system.users.id' FK - tometadata change 'system' schema to SOME_SCHEMA. Is it ok, or tometadata have to set schema to SOME_SCHEMA for street_id, locality_id

[sqlalchemy] conn.execute('CREATE SCHEMA %(s)s', {'s':s}) escape schema name,but it shouldn't, and raise ProgrammingError

2008-11-10 Thread sector119
Hi! I use PostgreSQL and when I try to create schema I use following command conn.execute('CREATE SCHEMA %(s)s', {'s':s}) I get raise exc.DBAPIError.instance(statement, parameters, e, connection_invalidated=is_disconnect) sqlalchemy.exc.ProgrammingError: (ProgrammingError) syntax error at or

[sqlalchemy] how to change table foreign key target schema?

2008-11-07 Thread sector119
Hi! I have people_table: people_table = sa.Table('people', meta.metadata, sa.Column('id', sa.types.Integer, primary_key=True, autoincrement=False), sa.Column('street_id', sa.types.Integer, sa.ForeignKey('streets.id'), nullable=False), sa.Column('first_name', sa.types.Unicode(255),