Re: [sqlalchemy] Possible bug with subqueryload

2011-09-28 Thread Simon King
On Wed, Sep 28, 2011 at 2:15 PM, Michael Bayer mike...@zzzcomputing.comwrote: that mapper.order_by thing is fixed in 0.7.3/0.6.9 tip. Brilliant - thanks again for all the time you put in to SA and this group, Simon -- You received this message because you are subscribed to the Google Groups

Re: [sqlalchemy] packages, modules and double imports - oh my!

2011-10-03 Thread Simon King
On Mon, Oct 3, 2011 at 4:24 PM, Chris Withers ch...@simplistix.co.ukwrote: On 03/10/2011 15:15, Michael Bayer wrote: ive no idea what __main__.py is either ? where's the SQLAlchemy exceptions here ? (keeping in mind i havent yet gone through all the steps to download a file...untar

Re: [sqlalchemy] Re: Working with large IN lists

2012-02-21 Thread Simon King
On Tue, Feb 21, 2012 at 3:24 PM, Manav Goel manav.goe...@gmail.com wrote: This depends upon the execution plan of the query and is more really a postgresql question. Google postgresql IN performance and you will get a good idea of it. By the look of your code, Second option would obviously be

Re: [sqlalchemy] Execute statement after each connect.

2012-05-14 Thread Simon King
On Mon, May 14, 2012 at 5:20 PM, Oliver Tonnhofer olt...@gmail.com wrote: Hi, how can I execute a statement for each new connection. I'm using the trigram module (pg_trgm) for PostgreSQL and I need to set a threshold by calling an SQL function for each new connection (`select

Re: [sqlalchemy] keeping long filter statements easily readable?

2012-05-28 Thread Simon King
On Sun, May 27, 2012 at 4:37 PM, Julien Lacroix ne...@aradriel.de wrote: I've stumbled across someof my old query and got certain problems to read my bunch of where statements. The editors word wrap function makes things just worse. whats your advance to keep long filter statements readable,

Re: [sqlalchemy] Session management with mod_wsgi and webapp2

2012-05-28 Thread Simon King
On Mon, May 28, 2012 at 12:58 AM, Bradley Mclain bradley.james.mcl...@gmail.com wrote: On Saturday, May 26, 2012 9:31:55 AM UTC+10, Michael Bayer wrote: On May 24, 2012, at 11:28 PM, Bradley Mclain wrote: Hi, Currently working on a project that use SQL alchemy with mod_wsgi,  webapp2 and

Re: [sqlalchemy] Re: how to get into PG database, is the url the right way? newbie question

2012-08-14 Thread Simon King
On Monday, August 13, 2012 9:23:43 PM UTC+2, Gery wrote: Hello, I'm new around here and I've been using SQLalchemy (SA) for a while. I work with PostGis (PG), OpenLayers (OL), ExtJS, GeoExtJS and now with the great SA and GeoAlchemy. I have one problem, I created a model where I defined one

Re: [sqlalchemy] Re: how to get into PG database, is the url the right way? newbie question

2012-08-14 Thread Simon King
On Tue, Aug 14, 2012 at 6:39 PM, Gery geryherb...@gmail.com wrote: Hello Simon, Thanks for your answer, acttually I don't use any web framework, I just did a html page and put Openlayers, GeoExt, and Ext code there. To display points/lines/polylines/rasters/etc., I use Mapserver, so I

Re: [sqlalchemy] Create tables from class declaration

2012-08-21 Thread Simon King
On Tue, Aug 21, 2012 at 5:25 PM, andrea crotti andrea.crott...@gmail.com wrote: The question is probably very simple, but I can't find an answer anywhere... Suppose I already have some tables declarad in a declarative way, as below, how do I create the database schema from them? I usually

Re: [sqlalchemy] SQLAlchemy with Flask -- hybrid models?

2012-08-22 Thread Simon King
On Wed, Aug 22, 2012 at 12:51 PM, David McKeone davidmcke...@gmail.com wrote: I've been using SQLAlchemy with Flask via the Flask extension Flask-SQLAlchemy. Everything works great so far, but I foresee a potential problem once I start to use my database model outside of Flask. In the future

Re: [sqlalchemy] SQLAlchemy with Flask -- hybrid models?

2012-08-22 Thread Simon King
On Wed, Aug 22, 2012 at 2:44 PM, David McKeone davidmcke...@gmail.com wrote: On Wednesday, August 22, 2012 2:33:01 PM UTC+1, David McKeone wrote: On Wednesday, August 22, 2012 2:23:28 PM UTC+1, Simon King wrote: On Wed, Aug 22, 2012 at 12:51 PM, David McKeone davidm...@gmail.com wrote

Re: [sqlalchemy] Copying Between Databases - Can I modify part of a Composite Key?

2012-09-27 Thread Simon King
On Thu, Sep 27, 2012 at 2:34 PM, Shawn Wheatley swheat...@gmail.com wrote: On Thursday, September 27, 2012 9:21:57 AM UTC-4, Shawn Wheatley wrote: the most idiomatic way to handle this is to merge the objects in: obj = session.merge(existing_object) this will emit a SELECT for the

Re: [sqlalchemy] live access to postgis database to use in ExtJS, OpenLayers, etc

2012-10-02 Thread Simon King
On Mon, Oct 1, 2012 at 11:38 PM, Gery . gameji...@hotmail.com wrote: thanks but I want to use that live access to search at first through ExtJS/GeoExtJS/OpenLayers and through them there is only a url available (protocol HTTP), I also need to get the data as GeoJSON, so I think GeoAlchemy

Re: [sqlalchemy] SQLALCHEMY query.

2012-10-03 Thread Simon King
On Wed, Oct 3, 2012 at 5:02 PM, Trinath Somanchi trinath.soman...@gmail.com wrote: Hi- I have a sql query which is returning 2 rows. But when is transformed to ORM query, its not returning any rows. My SQL Statement: select distinct(inst.hostname) as server_name, fip.address as

Re: [sqlalchemy] SQLALCHEMY query.

2012-10-03 Thread Simon King
On Wed, Oct 3, 2012 at 5:23 PM, Trinath Somanchi trinath.soman...@gmail.com wrote: Hi Simon- I have update my ORM query this way result = session.query(models.Instance.hostname.distinct(),models.FixedIp.address,models.VirtualInterface.address).\

Re: [sqlalchemy] Re: isolation level not supported on MySQL 3.23

2012-10-22 Thread Simon King
On Tue, Sep 18, 2012 at 1:33 PM, Ids idsvandermo...@gmail.com wrote: and of course sqlalchemy 0.5.1 did work. So something in sqlalchemy 0.7.8 broke... I just hit this error myself when using the latest SQLAlchemy (both 0.7.9 and latest 'default' from hg) against MySQL 3.23.58. Adding the

Re: [sqlalchemy] Re: isolation level not supported on MySQL 3.23

2012-10-22 Thread Simon King
On Mon, Oct 22, 2012 at 3:29 PM, Simon King si...@simonking.org.uk wrote: On Tue, Sep 18, 2012 at 1:33 PM, Ids idsvandermo...@gmail.com wrote: and of course sqlalchemy 0.5.1 did work. So something in sqlalchemy 0.7.8 broke... I just hit this error myself when using the latest SQLAlchemy

Re: [sqlalchemy] [Q] Transform a select part of a query

2012-10-24 Thread Simon King
On Wed, Oct 24, 2012 at 3:59 PM, Ladislav Lenart lenart...@volny.cz wrote: Hello. Suppose I have the following query: def people_older_than(age): q = session.query(Person).order_by(Person.name) q = q.filter(Person.age age) return q It returns a subset of Person instances.

Re: [sqlalchemy] max() min() string lengths?

2013-01-04 Thread Simon King
On 4 Jan 2013, at 03:08, James Hartley jjhart...@gmail.com wrote: Embarrassingly, I'm gotten lost in calling SQL functions in SQLAlchemy 0.7.1. I can boil the problem down to the following table structure: CREATE TABLE words ( id INTEGER NOT NULL, timestamp DATETIME NOT

Re: [sqlalchemy] namedTuple with conflicting attributes

2013-01-18 Thread Simon King
On 18 Jan 2013, at 12:15, Kenny bill...@mpimp-golm.mpg.de wrote: Hey all, I'm quite new to SQLAlchemy and I've been struggling to get the following to work. When one queries with specific entities, the resulting namedTuples might have overlapping keys. e.g. sample =

Re: [sqlalchemy] query.filter AND ( ... OR ... OR ) how to?

2013-01-23 Thread Simon King
On Wed, Jan 23, 2013 at 11:30 AM, Jose Soares jose.soa...@sferacarta.com wrote: Hi all, I'm trying to compile a query to avoid Oracle limit of 1000 in IN(): def chunks(l, n): Yield successive n-sized chunks from l. for i in xrange(0, len(l), n): yield l[i:i+n]

Re: [sqlalchemy] updating with a Session ?

2013-02-06 Thread Simon King
On Wed, Feb 6, 2013 at 2:05 AM, Jonathan Vanasco jonat...@findmeon.com wrote: I use SqlAlchemy in a Pyramid app. All my models, connections, etc are within and set up by Pyramid. I'm trying to do a maintenance script, and am a bit confused. In my script, thanks to a bootstraped commandline

Re: [sqlalchemy] updating with a Session ?

2013-02-06 Thread Simon King
On Wed, Feb 6, 2013 at 11:19 AM, Simon King si...@simonking.org.uk wrote: On Wed, Feb 6, 2013 at 2:05 AM, Jonathan Vanasco jonat...@findmeon.com wrote: I use SqlAlchemy in a Pyramid app. All my models, connections, etc are within and set up by Pyramid. I'm trying to do a maintenance script

Re: [sqlalchemy] Low performance when reflecting tables via pyodbc+mssql

2013-02-12 Thread Simon King
On Tue, Feb 12, 2013 at 10:12 AM, shaung shaun.g...@gmail.com wrote: For the following code: from sqlalchemy import create_engine, MetaData, Table dbengine = create_engine('mssql+pyodbc://MYDSN') dbmeta = MetaData() dbmeta.bind = dbengine def get_table(name): table = DBTable(name,

Re: [sqlalchemy] Low performance when reflecting tables via pyodbc+mssql

2013-02-12 Thread Simon King
On Tue, Feb 12, 2013 at 11:29 AM, shaung shaun.g...@gmail.com wrote: On Tuesday, February 12, 2013 7:18:37 PM UTC+9, Simon King wrote: If you add echo='debug' to your create_engine call, SA will log all calls to the database and rows returned, which might give you an idea of where all

Re: [sqlalchemy] Proper way to do processing across entire db?

2013-02-21 Thread Simon King
On 21 Feb 2013, at 22:44, Victor Ng vicng...@gmail.com wrote: On Thursday, February 21, 2013 1:03:49 PM UTC-8, A.M. wrote: On Thu, 21 Feb 2013 12:52:42 -0800 (PST), Victor Ng vicn...@gmail.com wrote: I do a lot of processing on large amount of data. The common pattern we follow is:

Re: [sqlalchemy] is there a more proper way to chain dynamic or clauses ?

2013-02-22 Thread Simon King
On Fri, Feb 22, 2013 at 1:31 AM, Jonathan Vanasco jonat...@findmeon.com wrote: basd on a bunch of error messages, this example works... criteria = ( ('male',35),('female','35) ) query = session.query( model.Useraccount ) ands = [] for set_ in criteria :

Re: [sqlalchemy] Storing and Retrieving BLOB in SqlAlchemy

2013-02-27 Thread Simon King
On Tue, Feb 26, 2013 at 2:44 PM, dalia dalia@gmail.com wrote: Hi, My intention is - to store .xls, .doc and .pdf files (with images in them) to store in a Oracle database and retrieve them. I'm using SQLAlchemy declarative code. The problem is, the data gets stored in the database but

Re: [sqlalchemy] Updating a table using sqlalchemy.sql.expression update

2013-03-07 Thread Simon King
This is an unusual way to update an object that you've already retrieved: result = session.query(Executions). \ filter_by(id=execution_id).first() if result.end_date is None: e = update(Executions).where(Executions.id==bindparam(execution_id)). \

Re: [sqlalchemy] How Can I Build a ForeignKey to a Table Which Has Multiple Primary Keys?

2013-03-07 Thread Simon King
I don't understand your model. Can you have multiple rows in the Exchange table which all have the same value for Exchange.exchange? If so, and if you want PhoneNumber to be able to point to a single one of those rows, then it needs 2 columns to do that (one to point to Exchange.exchange and one

Re: [sqlalchemy] Updating a table using sqlalchemy.sql.expression update

2013-03-07 Thread Simon King
)), Column(files_id, Integer, ForeignKey(files.id)) ) The error: AttributeError: 'Table' object has no attribute 'process_id' Why can not I access process_id? 2013/3/7 Simon King si...@simonking.org.uk The ORM tutorial covers querying with joins: http

Re: [sqlalchemy] How Can I Build a ForeignKey to a Table Which Has Multiple Primary Keys?

2013-03-07 Thread Simon King
You have to put your ForeignKeyConstraint in the __table_args__ for the PhoneNumber class - see http://docs.sqlalchemy.org/en/rel_0_8/orm/extensions/declarative.html#table-configuration for details. Something like: class PhoneNumber(db.Model): __tablename__ = 'phonenumbers'

Re: [sqlalchemy] How Can I Build a ForeignKey to a Table Which Has Multiple Primary Keys?

2013-03-07 Thread Simon King
(I'm guessing?). Is there a way to force this to execute in a specific order? -Randall On Thu, Mar 7, 2013 at 4:06 PM, Simon King si...@simonking.org.uk wrote: You have to put your ForeignKeyConstraint in the __table_args__ for the PhoneNumber class - see http://docs.sqlalchemy.org/en

Re: [sqlalchemy] SA connect to database remotely

2013-03-13 Thread Simon King
On Wed, Mar 13, 2013 at 4:00 PM, junepeach juneyh...@gmail.com wrote: Hello All, Using sqlalchemy ORM, I have no problem to create a database in mysql locally. If I have mysql installed in a different machine (ip address: 10.7.0.127), and my tables defined in this machine (10.7.0.121). Now

Re: [sqlalchemy] joinedload + limit

2013-03-21 Thread Simon King
On 21 Mar 2013, at 20:56, Jose Neto jbastosn...@gmail.com wrote: Given the following statement: p = db.query(Profile).options(joinedload('*')).filter_by(id=p.id).limit(1).one() I will get a subquery + a join, instead of a pure join: SELECT [...] FROM (SELECT profile.id AS

Re: [sqlalchemy] complex many to many relationship

2013-03-27 Thread Simon King
On Wed, Mar 27, 2013 at 4:13 PM, Kevin S kevinrst...@gmail.com wrote: Setup: I have been learning SQL Alchemy to build a prototype (proof of concept) Flask app for our internal website. We want to replace our current site, which is made entirely of slow python CGIs and raw SQL. Our database

Re: [sqlalchemy] implementing one-to-many relationship?

2013-04-15 Thread Simon King
On Mon, Apr 15, 2013 at 3:39 AM, James Hartley jjhart...@gmail.com wrote: On Thu, Apr 4, 2013 at 1:39 PM, Michael Bayer mike...@zzzcomputing.com wrote: the requery is due to the default expire_on_commit of session.commit(): http://docs.sqlalchemy.org/en/rel_0_8/orm/session.html#committing.

Re: [sqlalchemy] How to map a oracle table with long table name

2013-04-17 Thread Simon King
On Wed, Apr 17, 2013 at 2:38 AM, Evan Jon evanjon@gmail.com wrote: Hello all, I want to map a table whose name is BAND_ORDER_OF_LOCAL_TESTING. class BandOrderOfLocalTesting(Base): __TABLENAME__ = 'BAND_ORDER_OF_LOCAL_TESTING' order_id = Column(order_id, Number(18),

Re: [sqlalchemy] Re: views declarative?

2013-04-17 Thread Simon King
On Wed, Apr 17, 2013 at 2:59 PM, James Hartley jjhart...@gmail.com wrote: On Wed, Apr 17, 2013 at 6:20 AM, Lele Gaifax l...@metapensiero.it wrote: James Hartley jjhart...@gmail.com writes: Is it possible to map Table instances back to classes defined through declarative_base()? ...I

Re: [sqlalchemy] Testing sqlalchemy applications

2013-04-23 Thread Simon King
On Tue, Apr 23, 2013 at 6:54 AM, Paradox para...@pobox.com wrote: I have a question related to sqlalchemy and testing, not sure if this is the best place to ask so let me know if I am asking here in error. I am trying to learn to write and run tests using py.test. Currently I am working on a

Re: [sqlalchemy] Testing sqlalchemy applications :p:

2013-04-23 Thread Simon King
On Tue, Apr 23, 2013 at 2:08 PM, Paradox para...@pobox.com wrote: On 04/23/2013 04:31 PM, Simon King wrote: On Tue, Apr 23, 2013 at 6:54 AM, Paradox para...@pobox.com wrote: I have a question related to sqlalchemy and testing, not sure if this is the best place to ask so let me know if I

Re: [sqlalchemy] Using UniqueConstraint or unique=True

2013-05-03 Thread Simon King
On Thu, May 2, 2013 at 11:43 PM, Paradox para...@pobox.com wrote: I am trying to ensure that my table doesn't allow duplicate rows. The table is defined (in SqlAlchemy 0.8): class User(Base): __tablename__ = 'user' id = Column(Integer, primary_key=True) lname =

Re: [sqlalchemy] tablet version cache

2013-05-09 Thread Simon King
On Thu, May 9, 2013 at 9:02 AM, Treeve Jelbert tre...@scarlet.be wrote: i have started having problems when casting spells. I get message: The tablet version cache is damaged, removing it! In some cases it appears multiple times. I tried 'cleanse --tablet' but it makes no difference. Any

Re: [sqlalchemy] EAV Optimizations

2013-05-16 Thread Simon King
On 16 May 2013, at 21:21, Michael Bayer mike...@zzzcomputing.com wrote: On May 16, 2013, at 4:07 PM, Julien Cigar jci...@ulb.ac.be wrote: On 05/14/2013 16:58, Michael Bayer wrote: When you are storing data with key/values, where the set of keys is part of the data. Storing

Re: [sqlalchemy] Are consecutive query.get calls supposed to send a single SELECT query?

2013-05-21 Thread Simon King
On Tue, May 21, 2013 at 4:31 PM, Etienne Rouxel rouxel.etie...@gmail.com wrote: Hello In my program, I was trying to guess why so many SQL queries were sent while some could have been avoided with the help of the identity map. So, I reduced my program to what is below and wrote 3 times the

Re: [sqlalchemy] sqlite and max_overflow

2013-05-28 Thread Simon King
I think turbogears is loading your sqlalchemy parameters from a config file (dev.cfg perhaps?). You should look for a line of the form sqlalchemy.max_overflow = X and delete it. Hope that helps, Simon On Tue, May 28, 2013 at 10:34 AM, jo jose.soa...@sferacarta.com wrote: Thanks for the tip,

Re: [sqlalchemy] How to update PickleType column using DBSession.execute()

2013-05-31 Thread Simon King
On Fri, May 31, 2013 at 10:28 AM, sajuptpm sajup...@gmail.com wrote: How to update PickleType column using DBSession.execute() class MyTable(DeclarativeBase): __tablename__ = 'mytable' context = Column(PickleType) Attempt 1 context = {k1:{n1:bbla}, k2:{n2:bbla}}

Re: [sqlalchemy] [psql] string escaping quirk in like clauses

2013-06-27 Thread Simon King
On Thu, Jun 27, 2013 at 11:01 AM, Burak Arslan burak.ars...@arskom.com.tr wrote: Hi, First, some background: psql (9.2.4) Type help for help. somedb=# create table a(a varchar(5)); CREATE TABLE somedb=# insert into a values (E'\\'); INSERT 0 1 somedb=# select * from a where a = '\';

Re: [sqlalchemy] [psql] string escaping quirk in like clauses

2013-06-28 Thread Simon King
On Fri, Jun 28, 2013 at 2:11 AM, Burak Arslan burak.ars...@arskom.com.tr wrote: On 06/27/13 13:41, Simon King wrote: Remember that Python also has its own string escaping. When you write a literal '\\' in Python, you are creating a string containing a single backslash. Hi Simon, I'm aware

Re: [sqlalchemy] [psql] string escaping quirk in like clauses

2013-06-28 Thread Simon King
On Fri, Jun 28, 2013 at 11:05 AM, Burak Arslan burak.ars...@arskom.com.tr wrote: On 06/28/13 11:55, Simon King wrote: When you write this: e.execute(t.select(t.c.a.like('\\'))) ...the pattern that you are sending to SA is a single backslash, and SA is forwarding that directly to PG. What do

Re: [sqlalchemy] Generated update command is alway schosing alternative field names

2013-07-11 Thread Simon King
On Thu, Jul 11, 2013 at 4:30 PM, Richard Gomes rgomes.i...@gmail.com wrote: hello, I've previously defined inserts and updates by hand in my application, which is working fine, not using SQLAlchemy at the moment. At this point, I'd like to employ SQLAlchemy to generate these inserts and

Re: [sqlalchemy] filtering by variable attribute names

2013-07-23 Thread Simon King
On Tue, Jul 23, 2013 at 8:17 AM, Matthew Pounsett matt.pouns...@gmail.com wrote: Does the ORM allow for filtering by a variable attribute name? I found this discussion using raw SQL: https://groups.google.com/d/topic/sqlalchemy/Axa-0thwOR8/discussion But the suggestion doesn't seem to apply

Re: [sqlalchemy] Extending sqlalchemy.schema.Table

2013-08-01 Thread Simon King
It's a horrible hack, but did you know that you can change the class of an instance by assigning to its __class__ attribute? I've no idea if SA does anything that would stop this from working, but you could try it. Start by creating a subclass of Table with your extra methods, then iterate over

Re: [sqlalchemy] Creating one-to-many relationship: child class returns empty list after trying to enter data

2013-08-10 Thread Simon King
On 10 Aug 2013, at 03:42, csdr...@gmail.com wrote: This is driving me a little crazy so hopefully someone here can help. This is my first time working with sqlalchemy (v0.8). Python is v2.7.2 and MySQL is v14.14. The (heavily) summarized code is as follows: class Price(Base):

Re: [sqlalchemy] self-referential many-to-many relationships and mixins

2013-08-13 Thread Simon King
On Tue, Aug 13, 2013 at 2:07 PM, till.plewe till.pl...@gmail.com wrote: I am using python 3.3 and sqlalchemy 0.8.2 I am trying to define a self-referential many-to-many relationship for a class where the primary key is provided by a mixin. Defining the primary directly in the class works.

Re: [sqlalchemy] Updating a one-to-many relationship

2013-08-14 Thread Simon King
I think you may be confused about the relationship properties you have here. As far as I can tell, a Creator can have many companies, but each Company has only one creator, correct? So Company.creator should only ever be an instance of Creator (or None), whereas Creator.companies should be a list.

Re: [sqlalchemy] Updating a one-to-many relationship

2013-08-15 Thread Simon King
, August 14, 2013 6:18:51 AM UTC-4, Simon King wrote: I think you may be confused about the relationship properties you have here. As far as I can tell, a Creator can have many companies, but each Company has only one creator, correct? So Company.creator should only ever be an instance

Re: [sqlalchemy] alternate way to filter queries

2013-08-26 Thread Simon King
On 26 Aug 2013, at 19:15, lars van gemerden l...@rational-it.com wrote: On Monday, August 26, 2013 5:23:07 PM UTC+2, Michael Bayer wrote: On Aug 26, 2013, at 11:14 AM, lars van gemerden la...@rational-it.com wrote: Hi all, This might be a bit of a stretch but here it goes: Say that

Re: [sqlalchemy] Occasional IntegrityError when identifying model not by its ID

2013-08-27 Thread Simon King
On Tue, Aug 27, 2013 at 1:40 PM, herzaso herz...@gmail.com wrote: I have a model with an ID column set as the primary key, though i'd like to be able to identify records by 3 other columns. For this situation, I've added a classmethod that will fetch the record if found or a new record if not.

Re: [sqlalchemy] sqlalchemy.exc.InvalidRequestError: Instance 'MYCALSSTABLENAME at 0x994a90c' is not persisted

2013-08-27 Thread Simon King
On Mon, Aug 26, 2013 at 11:17 PM, Mohsen Pahlevanzadeh m.pahlevanza...@gmail.com wrote: Dear all, i have the following delete record function: def deleteRecord(self,tableObj): self.session.delete(tableObj); self.session.commit(); When i call the abobe function,

Re: [sqlalchemy] Occasional IntegrityError when identifying model not by its ID

2013-08-27 Thread Simon King
On Tue, Aug 27, 2013 at 2:31 PM, herzaso herz...@gmail.com wrote: On Tuesday, August 27, 2013 3:55:50 PM UTC+3, Simon King wrote: On Tue, Aug 27, 2013 at 1:40 PM, herzaso her...@gmail.com wrote: I have a model with an ID column set as the primary key, though i'd like to be able

Re: [sqlalchemy] Re: sqlalchemy.exc.InvalidRequestError: Instance 'MYCALSSTABLENAME at 0x994a90c' is not persisted

2013-08-27 Thread Simon King
session.delete() only works with instances which are already part of that session. Here's an example: ddd = session.query(SellersTable).filter_by(name_type=1).one() session.delete(ddd) This will SELECT the row from the database first, then perform the DELETE using the object's primary key.

Re: [sqlalchemy] copying data w/o over-writing autoincrement fields

2013-08-29 Thread Simon King
On Thu, Aug 29, 2013 at 3:54 PM, Aaron Krister Johnson akjmi...@gmail.com wrote: Hi all, I have a script that bulk copies relevant data from one database server to another using the neat-o MetaData features in SQLAlchemy. My script is a custom variation of this script:

Re: [sqlalchemy] watining for table metadata lock

2013-08-29 Thread Simon King
On Thu, Aug 29, 2013 at 4:48 PM, diverman pa...@schon.cz wrote: Hi, we observed deadlock-like problem on our multi-component system with mysql database. Our setup: 1) MySQL server 5.5 with many MyISAM tables Foo_timestamp, one per day (like partitioning) 2) C++ backend daemon *

Re: [sqlalchemy] watining for table metadata lock

2013-08-29 Thread Simon King
On Thu, Aug 29, 2013 at 5:20 PM, Simon King si...@simonking.org.uk wrote: On Thu, Aug 29, 2013 at 4:48 PM, diverman pa...@schon.cz wrote: Hi, we observed deadlock-like problem on our multi-component system with mysql database. Our setup: 1) MySQL server 5.5 with many MyISAM tables

Re: [sqlalchemy] watining for table metadata lock

2013-08-29 Thread Simon King
On Thu, Aug 29, 2013 at 6:01 PM, diverman pa...@schon.cz wrote: Dne čtvrtek, 29. srpna 2013 18:23:12 UTC+2 Simon King napsal(a): On Thu, Aug 29, 2013 at 5:20 PM, Simon King si...@simonking.org.uk wrote: On Thu, Aug 29, 2013 at 4:48 PM, diverman pa...@schon.cz wrote: Hi, we observed

Re: [sqlalchemy] many queries select if in cycle has insert into table

2013-08-30 Thread Simon King
On Fri, Aug 30, 2013 at 9:10 AM, Дмитрий Косолапов kosolapo...@gmail.com wrote: my program code: engine = create_engine(connect_str, echo=True) Session = sessionmaker(bind=engine) for bar in default_session.query(BarLog)[:3]: conf = ManagerConfig(indicator_config='',

Re: [sqlalchemy] an unkown object in code.

2013-09-01 Thread Simon King
On 1 Sep 2013, at 18:27, Mohsen Pahlevanzadeh m.pahlevanza...@gmail.com wrote: Dear all, Before apply code or writing code from a documentation, At first i test it into test.py, Now ,I read the following doc: conjuctions in sqlalchemy I supposed users a class such as tables class:

Re: [sqlalchemy] sqlalchemy.exc.ArgumentError: Valid strategies for session synchronization are 'evaluate', 'fetch', False

2013-09-01 Thread Simon King
On 1 Sep 2013, at 22:30, Mohsen Pahlevanzadeh m.pahlevanza...@gmail.com wrote: Dear all, i get the following traceback for session.query().filter(sellers.c.name == 'golrang').delete('sellers') line: /// Traceback (most recent call last): File

Re: [sqlalchemy] Occasional IntegrityError when identifying model not by its ID

2013-09-02 Thread Simon King
this problem before I move on ... On Tuesday, August 27, 2013 5:24:07 PM UTC+3, Simon King wrote: On Tue, Aug 27, 2013 at 2:31 PM, herzaso her...@gmail.com wrote: On Tuesday, August 27, 2013 3:55:50 PM UTC+3, Simon King wrote: On Tue, Aug 27, 2013 at 1:40 PM, herzaso her...@gmail.com wrote: I

Re: [sqlalchemy] Occasional IntegrityError when identifying model not by its ID

2013-09-02 Thread Simon King
connection Regarding your second remark, the answer is yes, the error was due to the unique constraint on those columns BTW: I'm working on MySQL On Monday, September 2, 2013 1:31:12 PM UTC+3, Simon King wrote: I don't really know the answer, but I'd be interested in the results

Re: [sqlalchemy] Occasional IntegrityError when identifying model not by its ID

2013-09-02 Thread Simon King
have it set as REPEATABLE READ. However, I don't use transactions in sqlalchemy On Monday, September 2, 2013 3:08:58 PM UTC+3, Simon King wrote: Do you know what transaction isolation level you are running at? The default apparently is REPEATABLE READ: http://dev.mysql.com/doc/refman/5.6/en

Re: [sqlalchemy] Occasional IntegrityError when identifying model not by its ID

2013-09-02 Thread Simon King
replace the transaction isolation level? On Monday, September 2, 2013 3:29:25 PM UTC+3, Simon King wrote: What exactly do you mean by not using transactions? The Session always works within a transaction: http://docs.sqlalchemy.org/en/rel_0_8/orm/session.html#managing-transactions I

Re: [sqlalchemy] Occasional IntegrityError when identifying model not by its ID

2013-09-02 Thread Simon King
it a try with a session.close to see if it helps (although I think I had complaints from users running the same API several times - and each time, at the end of my REST APIs I run session.close) On Monday, September 2, 2013 3:58:02 PM UTC+3, Simon King wrote: I'm no expert on isolation levels - I

Re: [sqlalchemy] error related to setting attribute to same value twice

2013-09-02 Thread Simon King
On Mon, Sep 2, 2013 at 4:01 PM, lars van gemerden l...@rational-it.com wrote: Hi all, I have a one-to-one and many-to-one relationship (with an association table in the middle; Report.author-assoctable-Person.reports; why the table in the middle, you might ask, well it's a long story) and i

Re: [sqlalchemy] error related to setting attribute to same value twice

2013-09-02 Thread Simon King
-it.com +31 6 26 88 55 39 On 2 sep. 2013, at 17:39, Simon King si...@simonking.org.uk wrote: On Mon, Sep 2, 2013 at 4:01 PM, lars van gemerden l...@rational-it.com wrote: Hi all, I have a one-to-one and many-to-one relationship (with an association

Re: [sqlalchemy] error related to setting attribute to same value twice

2013-09-02 Thread Simon King
session, i'd have to check. What actually happens if you add the same instance to a second session? CL On Mon, Sep 2, 2013 at 8:23 PM, Simon King si...@simonking.org.uk wrote: Without knowing your application it's very difficult to know... Is there any chance that the second object

Re: [sqlalchemy] error related to setting attribute to same value twice

2013-09-03 Thread Simon King
way, but it might pop up again. I'll keep merge in mind (i've run into the is already attached to session before). Thank you, Lars On Monday, September 2, 2013 9:18:11 PM UTC+2, Simon King wrote: Dunno, let's try it: import sqlalchemy as sa import sqlalchemy.orm as saorm from

Re: [sqlalchemy] Occasional IntegrityError when identifying model not by its ID

2013-09-03 Thread Simon King
with this issue... not only do I feel helpless, I don't have any clue on how to get around it ... What if I make the change without the session? Would the session pick up the changes on its first query? On Monday, September 2, 2013 3:58:02 PM UTC+3, Simon King wrote: I'm no expert on isolation

Re: [sqlalchemy] Occasional IntegrityError when identifying model not by its ID

2013-09-03 Thread Simon King
logged-in users) what are the odds that the same user will get the same error 10 times? On 3 Sep, 2013 3:05 PM, Simon King si...@simonking.org.uk wrote: Race conditions can happen at any time, not just when the system is under heavy load. You only need 2 requests to arrive at approximately

Re: [sqlalchemy] Occasional IntegrityError when identifying model not by its ID

2013-09-03 Thread Simon King
- From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] On Behalf Of Simon King Sent: Tuesday, September 03, 2013 3:28 PM To: sqlalchemy@googlegroups.com Subject: Re: [sqlalchemy] Occasional IntegrityError when identifying model not by its ID OK, I agree that doesn't sound like

Re: [sqlalchemy] query question

2013-09-04 Thread Simon King
On Wed, Sep 4, 2013 at 12:05 PM, lars van gemerden l...@rational-it.com wrote: I think i must be reading over something, but: is there a way to delay the selection of attributes in a query; something like session.query(Person).filter(Person.age 100).select(Person.name).first()

Re: [sqlalchemy] Occasional IntegrityError when identifying model not by its ID

2013-09-05 Thread Simon King
at the beginning of each request will do the job? Thanks, Ofir On Tuesday, September 3, 2013 3:54:16 PM UTC+3, Simon King wrote: I don't honestly know, but if this were my project I would be trying very hard to ensure that both (session.commit or session.rollback) followed by session.close were

Re: [sqlalchemy] Occasional IntegrityError when identifying model not by its ID

2013-09-06 Thread Simon King
thoughts? Can you make sense of this issue being related to certain computers? Thanks, Ofir On Thursday, September 5, 2013 1:13:49 PM UTC+3, Simon King wrote: (Remember, I still know next to nothing about Tornado, so this is pure assumption on my part) By default, SQLAlchemy scoped

Re: [sqlalchemy] dynamic query with many parametters

2013-09-08 Thread Simon King
On 8 Sep 2013, at 02:36, Mohsen Pahlevanzadeh m.pahlevanza...@gmail.com wrote: Suppose i need to send a set of table field and a value to search, i found the following code: /// q = session.query(myClass) for attr, value in web_dict.items(): q =

Re: [sqlalchemy] Create Table scripts failing randomly - scripts work from sqlite3 driver but not sqlalchemy

2013-09-20 Thread Simon King
On 20 Sep 2013, at 08:15, monosij.for...@gmail.com wrote: I am trying to create multiple tables from a set of 'create table' scripts.The set of scripts are in a list and I am executing as below. The scripts create tables, all scripts tested and work through the sqlite3 driver fine -

Re: [sqlalchemy] Create Table scripts failing randomly - scripts work from sqlite3 driver but not sqlalchemy

2013-09-22 Thread Simon King
(statement, parameters) sqlite3.Warning: You can only execute one statement at a time. ... Hope this helps. Please let me know if you need anything else. Thank you again for all your help. Mono On Friday, September 20, 2013 7:07:57 PM UTC-4, Simon King wrote: On 20 Sep 2013, at 08

Re: [sqlalchemy] Create Table scripts failing randomly - scripts work from sqlite3 driver but not sqlalchemy

2013-09-23 Thread Simon King
, September 22, 2013 5:30:37 PM UTC-4, Simon King wrote: The documentation for the Python sqlite driver specifically says: execute() will only execute a single SQL statement. If you try to execute more than one statement with it, it will raise a Warning. Use executescript() if you want to execute

Re: [sqlalchemy] sqlalchemy postgresql error

2013-09-26 Thread Simon King
On Thu, Sep 26, 2013 at 11:09 AM, mew...@gmail.com wrote: windows 7 64bit, flask, sqlalchemy 0.8.2, postgresql latest Traceback (most recent call last): File E:/code/python/sqlalchemy-test/sql-test.py, line 30, in module db.session.add(admin) File

Re: [sqlalchemy] Session Management Issues While Integrating With Old Code

2013-10-04 Thread Simon King
On Fri, Oct 4, 2013 at 3:47 PM, Russell Holloway russ.d.hollo...@gmail.com wrote: Hello all, I am trying to migrate some custom ORM code to use SQLAlchemy instead for database interactions. I'm having some issues with proper session management. The main issue that seems to occur is the

Re: [sqlalchemy] Query for date between a range

2013-10-04 Thread Simon King
I'm not sure that will work on it's own, will it? When used in a class context (Plan.calculated_date), you will end up calling the date function with 3 SQLAlchemy column objects, which won't work. At a minimum, you'd need this: class Plan(Base): @hybrid_property def

Re: [sqlalchemy] Process guide - XML

2013-10-31 Thread Simon King
On Thu, Oct 31, 2013 at 11:20 AM, Sayth Renshaw flebber.c...@gmail.com wrote: Hi Looking for some guidance using SQLAlchemy. In particular using SQLAlchemy to parse an XML file to the database. I have read the docs in SQLAlchemy on creating database and classes and tables and then started

Re: [sqlalchemy] Am I doing it wrong?

2013-11-06 Thread Simon King
On Wed, Nov 6, 2013 at 3:28 AM, bsa bruc...@gmail.com wrote: After resisting ORM and database abstraction packages for a long time in favour of plain sqlite3, I decided to give SQLAlchemy's ORM features a try. I've managed to specify a schema and get objects in and out of tables. I'm not sure

Re: [sqlalchemy] Relationship id not set automatically?

2013-11-06 Thread Simon King
On Wed, Nov 6, 2013 at 11:48 AM, Victor Varvariuc victor.varvar...@gmail.com wrote: How can this be? Is this the intended behavior? ipdb customer = factory.new_customer(_with_id=True) ipdb with Session() as session: customer = session.merge(customer) ipdb customer Customer(id=10002,

Re: [sqlalchemy] add foreign key constraint

2013-11-14 Thread Simon King
On Thu, Nov 14, 2013 at 8:47 AM, jonas geiregat geiregatjo...@gmail.com wrote: I have a table called session which has foreign key constraints. I removed them and auto generated a migration script. The upgrade function is populated as expected but the downgrade function isn't. I searched

Re: [sqlalchemy] using Column.in_(a_large_list) is very slow.

2013-11-15 Thread Simon King
On 15 Nov 2013, at 17:00, John Kida jdk...@gmail.com wrote: Hi guys, i dont really think this is sqlalchemy issue, but thought someone might be able to tell me why. I have a large list of id values, over 100,000 that are given to me from a text file.. Now I need to pull all rows that

Re: [sqlalchemy] SQLSoup, whitespace

2013-11-16 Thread Simon King
On 16 Nov 2013, at 00:23, Tim Pierson tim.pier...@gmail.com wrote: Happy Friday night everyone. Maybe there's an easy way to deal with this: How can I use the SQLSoup insert function to update columns whose names contain whitespace? ie: db.table.insert(XML Schema Version=None) Are

Re: [sqlalchemy] Struggling with a join

2013-11-29 Thread Simon King
On Fri, Nov 29, 2013 at 1:55 PM, Glenn Wilkinson glenn.wilkin...@gmail.com wrote: Hi all, I'm struggling to get a join to work, as below: [...] #Table definitions table = Table('vends', MetaData(), Column('mac', String(64), primary_key=True),

Re: [sqlalchemy] Re: Struggling with a join

2013-11-29 Thread Simon King
Ah, OK, I see what you mean. The way that you are producing the JOIN, although it works, is probably not exactly what you wanted. With this: s=select([proxs.c.mac]).outerjoin(vends, proxs.c.mac == vends.c.mac) ...you are first creating a query that selects from the proxs table, then treating

Re: [sqlalchemy] Using flask-sqlalchemy BaseQuery and Pagination with multiple tables.

2014-01-08 Thread Simon King
On Wed, Jan 8, 2014 at 3:37 PM, Mark S dbs...@gmail.com wrote: Hi I can successfully use pagination with the following - mydata=Article.query.filter(Article.author_id==User.id).filter(User.id==g.user.id).paginate(page, POSTS_PER_PAGE, False) However, I need to fetch columns from multiple

  1   2   3   4   5   6   7   >