Re: [sqlalchemy] Callback for when orm data is load

2021-04-30 Thread Mike Bernson
, only_load_props)     else:     state._commit_all(dict_, session_identity_map) are there any events after this point in the loading/refresh process ? On 4/30/21 4:03 PM, Mike Bernson wrote: The load and refresh events is close to what I am looking for. I need to

Re: [sqlalchemy] Callback for when orm data is load

2021-04-30 Thread Mike Bernson
s well with eager loaders though. On Tue, Apr 27, 2021, at 3:43 PM, Mike Bernson wrote: That callback look like it happening before orm instances are created. I am looking for a callback that is after all the instances are created. I am using the events to get a list of instances that need

Re: [sqlalchemy] Callback for when orm data is load

2021-04-27 Thread Mike Bernson
te_state):     if orm_execute_state.is_orm_statement:     result = orm_execute_state.invoke_statement()     rdbm_events.run_created()     return result On Tue, Apr 27, 2021, at 12:35 PM, Mike Bernson wrote: I am moving from version 1.0.14 to version 1.4.11 of sqlalchemy. I need to g

[sqlalchemy] Callback for when orm data is load

2021-04-27 Thread Mike Bernson
I am moving from version 1.0.14 to version 1.4.11 of sqlalchemy. I need to get a callback when all of the data from orm query is loaded not just single instance. In the 1.0 version I created the session using query_cls: self.session = Session(bind=engine, autoflush=False,    _enable_transa

Re: [sqlalchemy] Problem build a query using just core

2014-09-16 Thread Mike Bernson
nter, m.c.current_balance ]).select_from(subq.join( m, and_( subq.c.max_invoice_date == m.c.invoice_date, subq.c.account == m.c.account, subq.c.cost_center == m.c.cost_center, m.c.current_balance > 0 ) ) ) print stmt On Sep 15, 2014, at 7:49 P

Re: [sqlalchemy] Problem build a query using just core

2014-09-15 Thread Mike Bernson
#x27;invoice_date', 'account', 'cost_center', unique=True), ) metadata.create_all() On 09/15/2014 07:04 PM, Michael Bayer wrote: if you want to send (simplified, succinct) table defs i can show you how to get that in core. On Sep 15, 2014, at 6:39 PM, Mike Bernson

[sqlalchemy] Problem build a query using just core

2014-09-15 Thread Mike Bernson
Given the table below I am trying to get the where statement built using just core. I have tried a number of thing and am not able to get the query built. I can get the query close but not correct. I must be missing something simple. The database is Mysql and SQLAchemy is 9.7 The query does wor

[sqlalchemy] Problem going from 0.7.10 to 0.8.7

2014-07-29 Thread Mike Bernson
I have started moving my code base from 0.7.10 to 0.8.7 as first step to getting to current version. (There code changes for me to get to 0.9.x where there are no code changes to run under 0.8.x) I have found a problem with a query that worked on 0.7.10 and now fails with a raise. The code is fa

[sqlalchemy] difference for type BigInteger between 0.6.6 and 0. 7.0b2

2011-03-07 Thread Mike Bernson
from sqlalchemy import * meta = MetaData() stx_setup = Table("stx_setup", meta, Column('id', BigInteger(display_width=20), primary_key=True, autoincrement=T rue), Column('cost_center', Integer(display_width=1), index=True, nullable=True), Column('AdministratorLicense', String(length=

[sqlalchemy] moving from mapper extension to events

2010-12-29 Thread Mike Bernson
Looking at the events for instances. The on_expire passes a list of attributes being expired but the on_refresh does not have a list of attribute being refresh. Can the list of attribute being refreshed be add to on_refresh event ? I am looking to move from using mapperextension to instance e

[sqlalchemy] Look for the best way to undelete a model

2010-11-04 Thread Mike Bernson
I have a transaction started with begin I then delete a record in the transaction. I then commit and the commit fails. I now want to continue by undelete the record but leave record in the session. I want to leave the record in the session because session is doing caching. The session is created

Re: [sqlalchemy] Having case problem with column name in postgresql

2010-06-10 Thread Mike Bernson
Michael Bayer wrote: On Jun 10, 2010, at 12:06 AM, Mike Bernson wrote: I am trying to access a postgres database with mixed case column names. I am using reflection to get the table. Here is my connect string: 'postgresql://:mike@/cedar_senior_services' The err

[sqlalchemy] Having case problem with column name in postgresql

2010-06-09 Thread Mike Bernson
I am trying to access a postgres database with mixed case column names. I am using reflection to get the table. Here is my connect string: 'postgresql://:mike@/cedar_senior_services' The error message: (ProgrammingError) column "active" does not exist LINE 1: select * from license where Active

Re: [sqlalchemy] restoring the TINYINT(1) to Boolean

2010-06-01 Thread Mike Bernson
Thanks Setting column.type worked like a charm for me. Michael Bayer wrote: On May 31, 2010, at 10:01 PM, Mike Bernson wrote: I would like to restore the TINYINT(1) for all tables. I am using reflection to get the tables. The docs talk about passing in override value for the columns that I

Re: [sqlalchemy] restoring the TINYINT(1) to Boolean

2010-05-31 Thread Mike Bernson
will try just setting column.type I have not thought about doing that. Setting the dialect.ischema_names will not work because I only want to get tinyint(1) not all tinyint. Michael Bayer wrote: On May 31, 2010, at 10:01 PM, Mike Bernson wrote: I would like to restore the TINYINT(1) for all

[sqlalchemy] restoring the TINYINT(1) to Boolean

2010-05-31 Thread Mike Bernson
I would like to restore the TINYINT(1) for all tables. I am using reflection to get the tables. The docs talk about passing in override value for the columns that I to want change from the database as parameters to the table object on when reflecting. Since I have no idea what columns are TINYIN

[sqlalchemy] problem with warning on reflection

2010-04-03 Thread Mike Bernson
I am getting warning using 0.6beta2. The database is mysql. I get the following warning: /usr/local/ltcd/lib/SQLAlchemy-0.6beta2-py2.6.egg/sqlalchemy/dialects/mysql/base.py:2241: SADeprecationWarning: Manually quoting ENUM value literals is deprecated. Supply unquoted values and use the quoti

[sqlalchemy] Re: making an instance read-only

2009-08-25 Thread Mike Bernson
There is a way to catch every modify event at the time it is being modify. This is some code I use to send events when attribute are modified. There is an attribute that you can put on the model class __sa_instrumentation_manager__ = SetListener and then here is code to handle modify events: c

[sqlalchemy] Re: Attribute events

2009-02-11 Thread Mike Bernson
s at the point at which the "AttributeImpl" is assembled. > > > Mike Bernson wrote: >> I am trying to move from 0.5beta4 to 0.5.2 >> >> The attribute events are giving me a problem >> >> The code worked in 0.5beta4 and now is broken. >&

[sqlalchemy] Attribute events

2009-02-11 Thread Mike Bernson
I am trying to move from 0.5beta4 to 0.5.2 The attribute events are giving me a problem The code worked in 0.5beta4 and now is broken. class base(object): __sa_instrumentation_manager__ = SetListener listener = ReceiveEvents() class SetListener(InstrumentationManager): def instru

[sqlalchemy] Re: How to handle using master and number of slaves

2008-11-08 Thread Mike Bernson
Glad to known that it that simple. Thanks Michael Bayer wrote: > > On Nov 8, 2008, at 3:07 PM, Mike Bernson wrote: > >> I am looking at how to have 2 engines a session. >> >> I want to be able to switch between engine used based on >> if any writes will be ha

[sqlalchemy] How to handle using master and number of slaves

2008-11-08 Thread Mike Bernson
I am looking at how to have 2 engines a session. I want to be able to switch between engine used based on if any writes will be happening to the data being read. I can tell if any data will be modify by if the transaction started by issues a begin. I want to setup a number of server doing Replic

[sqlalchemy] Re: Attribute extension in 0.5rc1

2008-09-28 Thread Mike Bernson
Michael Bayer wrote: > > On Sep 28, 2008, at 8:23 PM, Mike Bernson wrote: > >> The set method has changed from 0.5b3 to 0.5rc1. >> >> The old set method set the value before it called the set method >> in attribute extension. The new method set the value

[sqlalchemy] Attribute extension in 0.5rc1

2008-09-28 Thread Mike Bernson
The set method has changed from 0.5b3 to 0.5rc1. The old set method set the value before it called the set method in attribute extension. The new method set the value after the set method is called. This is cause me problems because the methods that I am dispatching to think the attribute is set

[sqlalchemy] Re: Problem with query and lazyload

2008-09-28 Thread Mike Bernson
act issue. > > > > > > > > > > > > On Sep 27, 2008, at 1:52 PM, Mike Bernson wrote: > >> I have a problem with row coming back form mapped class that has >> relations. >> >> The session is creat

[sqlalchemy] Re: Problem with query and lazyload

2008-09-27 Thread Mike Bernson
act issue. > > > > > > > > > > > > On Sep 27, 2008, at 1:52 PM, Mike Bernson wrote: > >> I have a problem with row coming back form mapped class that has >> relations. >> >> The session is created with: >> >> self.session = Session(bind=self._en

[sqlalchemy] Re: problem with mapped object in different database.

2008-09-27 Thread Mike Bernson
looks to be working. Michael Bayer wrote: > > On Sep 27, 2008, at 12:35 AM, Mike Bernson wrote: > >> I have a number of database that have the same tables in them. >> >> I create a session for 1 data and do some work. This work causes >> a number of table tabl

[sqlalchemy] Problem with query and lazyload

2008-09-27 Thread Mike Bernson
I have a problem with row coming back form mapped class that has relations. The session is created with: self.session = Session(bind=self._engine, autoflush=False, _enable_transaction_accounting=False, autocommit=True, weak_identity_map=True) The problem occurs with insta

[sqlalchemy] problem with mapped object in different database.

2008-09-26 Thread Mike Bernson
I have a number of database that have the same tables in them. I create a session for 1 data and do some work. This work causes a number of table table object to be reflected from the database and then mapped. This works fine. Now I Switch to another database which has the same tables. If I acce

[sqlalchemy] mapper extension

2008-05-20 Thread Mike Bernson
I am looking for a hook after a instance has been created, attribute populated and any initialization done. I have found populate_instance in the MapperExtension. It look like to close thing. Adding a hook to MapperExtension for after instance is created, populated, and any initialization by the

[sqlalchemy] Re: trunk is now on 0.5

2008-05-10 Thread Mike Bernson
Is the stuff from user_defined_state branch merge in ? If so is the __sa_instrument_class__ stuff the same ? Michael Bayer wrote: > hey list - > > as you might have noticed we've merged 0.5 into the trunk. this > version is already spectacular and I encourage everyone to start > poking a

[sqlalchemy] Re: access to relations without causing a loading

2008-04-04 Thread Mike Bernson
Michael Bayer wrote: > > On Apr 4, 2008, at 8:06 PM, Mike Bernson wrote: > >> user = Table('users', metadata, >> Column('id', Integer, primary_key=True), >> Column('account_name', String(64))) >> >>

[sqlalchemy] access to relations without causing a loading

2008-04-04 Thread Mike Bernson
user = Table('users', metadata, Column('id', Integer, primary_key=True), Column('account_name', String(64))) address = Table('mail', metadata, Column('id', Integer, primary_key=True), Column('user_id', Integer, ForeignKey('users.id')), Column

[sqlalchemy] Re: using a model inherits from dict

2008-03-29 Thread Mike Bernson
t inherit from dict. > > On Sat, Mar 29, 2008 at 3:08 PM, Mike Bernson <[EMAIL PROTECTED]> wrote: >> I am trying to use models that inherit from dict. >> >> The models use attribute access for the sqlachemy attributes and dict style >> access for gui stu

[sqlalchemy] using a model inherits from dict

2008-03-29 Thread Mike Bernson
I am trying to use models that inherit from dict. The models use attribute access for the sqlachemy attributes and dict style access for gui stuff. This allow me to do things like model[column_name].editable for gui to see if item should be grayed out and model.column_name for access the column

[sqlalchemy] Re: I am having a problem inserting records and getting a exception

2008-02-18 Thread Mike Bernson
You are correct. Sorry I some how skipped over the last entry. Thanks jason kirtland wrote: > Mike Bernson wrote: >> I have attached the code doing the write to the database >> and a traceback with local variable being display for >> each frame. >> >> I am

[sqlalchemy] I am having a problem inserting records and getting a exception

2008-02-18 Thread Mike Bernson
I have attached the code doing the write to the database and a traceback with local variable being display for each frame. I am also attaching a run with nothing catching the error so you can see the simple traceback with the exception. Here is output from mysql show this has gone a long way int

[sqlalchemy] Re: how to role back a delete from the session.

2008-02-08 Thread Mike Bernson
Michael Bayer wrote: > On Feb 8, 2008, at 1:06 PM, Mike Bernson wrote: > > >> I have a case where a delete was requested and on the commit to the >> transaction the delete fails with a >> integrity error. Problem is a foreign key constraint will not let >>

[sqlalchemy] how to role back a delete from the session.

2008-02-08 Thread Mike Bernson
I have a case where a delete was requested and on the commit to the transaction the delete fails with a integrity error. Problem is a foreign key constraint will not let the record be delete. Now I have a session which tries to delete this record any time I flush things. I have rolled back the

[sqlalchemy] Re: SQLAlchemy 0.4.2b released

2008-01-07 Thread Mike Bernson
Mike You just need pick letter that are after release. Thing like p1 is greater then release from the egg docs. (A note about versions: the egg runtime system understands typical version numbering schemes, so it knows that versions like "1.2a1" and "1.2rc5" are actually older than the plain ve

[sqlalchemy] Unicode data into Binary type

2008-01-07 Thread Mike Bernson
Database is mysql I am having a problem with unicode and binary type. I am using an XML parse the return Unicode strings. I have a table in mysql with the default character set as utf8 I set the charset to utf8 in the connect string to charset=utf8 I am trying to send a unicode string to the

[sqlalchemy] Re: doing replaces

2008-01-04 Thread Mike Bernson
r key in keys)) > ) > return text(statement, bindparams=[bindparam(key, > type_=table.c[key].type) for key in keys]) > > trans = conn.begin() > conn.execute(replace(mytable, ['one', 'two', 'three']), [{'one':1, > 'two&#x

[sqlalchemy] doing replaces

2008-01-04 Thread Mike Bernson
I have code that need to do a mysql replace instead of an insert. The quick hack to just create a string and execute has problems with quoting things, sql injection ... If a table.replace() is not easy to do is there a way to create a statement that works that way. If I could do a conn.execute(s

[sqlalchemy] Re: Weak Referencing Session

2007-09-11 Thread Mike Bernson
Is there any chance of making it an option to not have a weak reference ? How about something on the session level with sessionmaker ? Having it the session level would help me but not sure if make sense there. I have things in the model object that depend on the object not going away. I have

[sqlalchemy] Problem with tinyint(1) on mysql

2007-08-28 Thread Mike Bernson
Using SQLAlchemy version 0.4b4. When reflecting table from mysql database with tinyint(1) you get a boolean back. I think this is error because it returns a bad data type for tinyint(1). I have a database that work under 0.3.0 where to store a single digit I used tinyint(1) and now this breaks un

[sqlalchemy] Re: looking to make

2007-07-18 Thread Mike Bernson
sounds good. Looking forward to see it in 3.10dev jason kirtland wrote: > Mike wrote: >> can it also be added to 3.9 ? > > Sure, if there's another release in the 0.3 line the case-check > cache can go in. But the "only use SHOW CREATE" change will be > likely be a 0.4-only thing. > > -j >

[sqlalchemy] Re: looking to make

2007-07-18 Thread Mike Bernson
can it also be added to 3.9 ? jason kirtland wrote: > [this one seems to have been lost in googlegroups too, resending...] > > Mike wrote: >> I started looking to what is happen to get table information from >> mysql. >> >> I found that the following is issued for every table that is >> reflect

[sqlalchemy] looking to make

2007-07-17 Thread Mike Bernson
I started looking to what is happen to get table information from mysql. I found that the following is issued for every table that is reflected: 2007-07-18 00:29:08,158 INFO sqlalchemy.engine.base.Engine.0x..cc show variables like 'character_set%%' 2007-07-18 00:29:08,158 INFO sqlalchemy.engine

[sqlalchemy] Re: Exception raised on insert blob.

2007-05-25 Thread Mike Bernson
of mysqldb. Thanks for the help Michael Bayer wrote: > > On May 24, 2007, at 10:12 PM, Mike Bernson wrote: > >> It give me an error attaching output > > > well that tests passes for everyone else AFAIK, so maybe something is > up with either the way youre connectin

[sqlalchemy] Re: Exception raised on insert blob.

2007-05-24 Thread Mike Bernson
will do some more testing on friday afternoon. Michael Bayer wrote: > > On May 24, 2007, at 10:12 PM, Mike Bernson wrote: > >> It give me an error attaching output > > > well that tests passes for everyone else AFAIK, so maybe something is > up with either the way your

[sqlalchemy] Re: Exception raised on insert blob.

2007-05-24 Thread Mike Bernson
I also just tried using a blob to replace longblob as blob is in the list of types for mysql and longblob was not. I get the same error Mike Bernson wrote: > I am trying to insert binary data (PDF) into the follow table in mysql > 5.0.22 using python 2.4 and SQLAlchemy 3.7. >

[sqlalchemy] Exception raised on insert blob.

2007-05-24 Thread Mike Bernson
I am trying to insert binary data (PDF) into the follow table in mysql 5.0.22 using python 2.4 and SQLAlchemy 3.7. I get exception: sqlalchemy.exceptions.SQLError: (UnicodeDecodeError) 'ascii' codec can't decode byte 0xff in position 14: ordinal not in range(128) CREATE TABLE `mds_report` (

[sqlalchemy] Re: sqlalchemy lost connection?

2007-02-03 Thread Mike Bernson
Mysql has a timeout idle connection. You might be running into this. I think it defaults to 8 hours It sounds like you are running into the idle timeout. dischdennis wrote: > Hi I am using sqlalchemy with zope and when I have the server running > a while (> 6 hours) without interaction, I cannot

[sqlalchemy] Re: How to lock database row on select?

2006-11-15 Thread Mike Bernson
use the lockmode='update' on a query object. row_obj = query_obj.select(where, lockmode='update').execute() Basil Shubin wrote: > Hi friends! > > I have use SQLAlchemy 0.3 with MySQLdb 1.2.1 How I can lock row in > database table when I select it? So nobody can access it in same time. > BTW I

[sqlalchemy] Re: speed issues with inserting lots of long records.

2006-10-25 Thread Mike Bernson
to make sure that I am not overlooking something. Robin Munn wrote: > On 10/25/06, Mike Bernson <[EMAIL PROTECTED]> wrote: >> I am written a program that load mysql database from a flat file. >> The table I am loading has a large number of columns about 800. > > 800 col

[sqlalchemy] speed issues with inserting lots of long records.

2006-10-25 Thread Mike Bernson
I am written a program that load mysql database from a flat file. The table I am loading has a large number of columns about 800. Here is simple version of what I am doing: records = [] for line in lines: record = {} for col in columns: record[col] = line[info[col