[sqlalchemy] Best sql platform to use with sqlalchemy on a limited shared network

2014-03-27 Thread Eric Kiser
CURRENT SCENARIO: - we have been given access to a network hence we can share copy and paste files on it. We access it by ftp://xx.x.x.xx with a user and password. THE IDEA ON MIND: - Create a simple program that uses sqlalchemy to query sqlite database (this is finished but my sqlite file is on

[sqlalchemy] Delete fails using automap with joined inheritance

2014-03-27 Thread Adrian Robert
I have been using the automap extension with postgres, with an inheritance structure using the joined inheritance pattern. I could not figure out a way to have this reflected from the DB so I define the classes for this part of my schema explicitly, and when automap initializes, these classes g

Re: [sqlalchemy] this result object does not return rows. it has been closed automatically

2014-03-27 Thread Ni Wesley
MySQLdb has the same problem. So, no concurrent, I just use engine(with default connection pool) execute. Then, how to work around the problem, for my query operation, if catch this exception, query again? 在 2014年3月27日星期四UTC+8下午11时42分19秒,Michael Bayer写道: > > > On Mar 27, 2014, at 9:14 AM, Ni Wes

[sqlalchemy] Self-join and autoload

2014-03-27 Thread thatsanicehatyouhave
Hi, I'm trying to configure a table with autoload but can't quite get the syntax to set up a self-relationship. This is my abbreviated) schema: CREATE TABLE sdssphoto.photoobj ( pk bigint NOT NULL DEFAULT nextval('photoobj_pk_seq'::regclass), parent_photoobj_pk bigint CONSTRAINT photoobj_pk

Re: [sqlalchemy] Stored-procedure commit woes

2014-03-27 Thread Michael Bayer
On Mar 27, 2014, at 6:50 PM, Michael Bayer wrote: > > > if you really have to turn on this non-standard feature on, it needs to be > across the board for that particular engine, and would be like this: > > from sqlalchemy import event > > @event.listens_for(engine, "connect") > def conn(con

Re: [sqlalchemy] Stored-procedure commit woes

2014-03-27 Thread Michael Bayer
On Mar 27, 2014, at 5:51 PM, Dustin Oprea wrote: > > Direct example: > > def direct_test(): > import MySQLdb > conn = MySQLdb.connect(host='db.host.com', user='abc', passwd="def", > db="ghi", port=3307) > > conn.autocommit(True) > > c = conn.cursor() > c.execute(query) >

Re: [sqlalchemy] Stored-procedure commit woes

2014-03-27 Thread Michael Bayer
On Mar 27, 2014, at 6:43 PM, Michael Bayer wrote: > > On Mar 27, 2014, at 5:51 PM, Dustin Oprea wrote: > >> Thanks, Mike. >> >> >> Any idea why SA is falling down on this? >> >> > > this is not a SQLAlchemy issue, it is an issue with the DBAPI you're using. > If you're using MySQL-pyth

Re: [sqlalchemy] Stored-procedure commit woes

2014-03-27 Thread Michael Bayer
On Mar 27, 2014, at 5:51 PM, Dustin Oprea wrote: > Thanks, Mike. > > > Any idea why SA is falling down on this? > > this is not a SQLAlchemy issue, it is an issue with the DBAPI you're using. If you're using MySQL-python, you need to work up a test script using only MySQL-python directly

Re: [sqlalchemy] Stored-procedure commit woes

2014-03-27 Thread Dustin Oprea
Thanks, Mike. On Thursday, March 27, 2014 3:16:27 PM UTC-4, Michael Bayer wrote: ... > OK, you seem to have found the autocommit flag on text(), this is the > correct approach in this case. > > I can’t get your stored proc to run as creating a proc on my machine > produces some “thread stac

[sqlalchemy] Re: What are the ORM mechanics when appending a new association in an M to N relationship?

2014-03-27 Thread Darin Gordon
Thank you, everyone, for your extremely helpful responses. You really helped clear this matter up On Thursday, March 27, 2014 9:27:42 AM UTC-4, Darin Gordon wrote: > > Let me preface this by saying that I researched to the best of my > abilities the answers to my following inquiries. I would

Re: [sqlalchemy] Stored-procedure commit woes

2014-03-27 Thread Michael Bayer
On Mar 27, 2014, at 3:01 PM, Dustin Oprea wrote: > I'm having a problem where I'm doing writes to MySQL that aren't being > committed. I'm obviously calling the procedure from an execute(). I'm okay > with explicit commits, but since all of my data logic is in procedures (all > operations are

[sqlalchemy] Stored-procedure commit woes

2014-03-27 Thread Dustin Oprea
I'm having a problem where I'm doing writes to MySQL that aren't being committed. I'm obviously calling the procedure from an execute(). I'm okay with explicit commits, but since all of my data logic is in procedures (all operations are one step), autocommit is preferable. I'm using 0.9.1 . Unt

Re: [sqlalchemy] What are the ORM mechanics when appending a new association in an M to N relationship?

2014-03-27 Thread Michael Bayer
On Mar 27, 2014, at 9:27 AM, Darin Gordon wrote: > Let me preface this by saying that I researched to the best of my abilities > the answers to my following inquiries. I would not ask for help without > first trying to investigate this on my own. Asking through this forum is the > proverbia

Re: [sqlalchemy] 'MySQL server has gone away' on closing connection

2014-03-27 Thread Michael Bayer
what this looks like is that the connection is closed by the server due to the MySQL timeout, then SQLAlchemy's pool, when accessed, goes to recycle those connections, and does a close() on the existing one. Since they've been closed server side, the close() method raises. The pool recycle

Re: [sqlalchemy] 'MySQL server has gone away' on closing connection

2014-03-27 Thread Tim Tisdall
Ah, yeah, that seems like a reasonable way of handling it. I just don't get why I'm getting those exceptions, though, as I have it set to recycle pool connections every 4 hrs where the mysql setting is to expire connections after 8hrs. As far as I understand it, I shouldn't be getting messages li

Re: [sqlalchemy] Replacing a single column in a select (Core language)

2014-03-27 Thread Josh Kuhn
That works great. My one stumbling block was that the column objects couldn't be compared directly, so I compared their string representation (I had two separate calls to A.alias() which made `is` not a valid comparison in the comprehension) On Thu, Mar 27, 2014 at 11:49 AM, Michael Bayer wrote:

Re: [sqlalchemy] Replacing a single column in a select (Core language)

2014-03-27 Thread Michael Bayer
On Mar 27, 2014, at 10:08 AM, Josh Kuhn wrote: > I have a situation where I need to produce a select object, and then later, > one of the fields needs to be "zeroed" out conditionally. > > so something like: > > def select_ab(param): > from_obj = join(A, B, A.c.b == B.c.b) > return se

Re: [sqlalchemy] 'MySQL server has gone away' on closing connection

2014-03-27 Thread Michael Bayer
On Mar 27, 2014, at 10:03 AM, Tim Tisdall wrote: > Today I found the following traceback in my logs: > > 2014-03-27 13:55:59,876 ERROR [sqlalchemy.pool.QueuePool _close_connection > b'uWSGIWorker2Core14'] Exception closing connection at 0x7fecfdf6a140> > Traceback (most recent call last): >

Re: [sqlalchemy] this result object does not return rows. it has been closed automatically

2014-03-27 Thread Michael Bayer
On Mar 27, 2014, at 9:14 AM, Ni Wesley wrote: > It's not happening everytime. > > And I am not using mysql-python, instead, I use pymysql. > > So, the root cause is connection in bad state? > How to fix or work around from sqlalchemy side? I don’t really know, I’d need to have a short script

Re: [sqlalchemy] What are the ORM mechanics when appending a new association in an M to N relationship?

2014-03-27 Thread Simon King
On Thu, Mar 27, 2014 at 1:27 PM, Darin Gordon wrote: > Let me preface this by saying that I researched to the best of my abilities > the answers to my following inquiries. I would not ask for help without > first trying to investigate this on my own. Asking through this forum is > the proverbial

[sqlalchemy] Replacing a single column in a select (Core language)

2014-03-27 Thread Josh Kuhn
I have a situation where I need to produce a select object, and then later, one of the fields needs to be "zeroed" out conditionally. so something like: def select_ab(param): from_obj = join(A, B, A.c.b == B.c.b) return select([A.c.a, B.c.b, B.c.d], from_obj=from_obj).where(A.c.a == param

[sqlalchemy] Re: What are the ORM mechanics when appending a new association in an M to N relationship?

2014-03-27 Thread Tim Tisdall
Have you tried turning the SQLAlchemy logging on to see the SQL queries that are run on your sample program? I've found it very helpful when trying to debug why something is not working the way I expected. You _may_ be able to do it as follows: import logging logging.getLogger("sqlalchemy.eng

[sqlalchemy] 'MySQL server has gone away' on closing connection

2014-03-27 Thread Tim Tisdall
Today I found the following traceback in my logs: 2014-03-27 13:55:59,876 ERROR [sqlalchemy.pool.QueuePool _close_connection b'uWSGIWorker2Core14'] Exception closing connection Traceback (most recent call last): File "/sites/ColanderAlchemy/SQLAlchemy-0.9.3-py3.3-linux-x86_64.egg/sqlalchemy/p

[sqlalchemy] What are the ORM mechanics when appending a new association in an M to N relationship?

2014-03-27 Thread Darin Gordon
Let me preface this by saying that I researched to the best of my abilities the answers to my following inquiries. I would not ask for help without first trying to investigate this on my own. Asking through this forum is the proverbial end of the line, so thanks for taking any time to read and

Re: [sqlalchemy] this result object does not return rows. it has been closed automatically

2014-03-27 Thread Ni Wesley
It's not happening everytime. And I am not using mysql-python, instead, I use pymysql. So, the root cause is connection in bad state? How to fix or work around from sqlalchemy side? Wesley 在 2014年3月27日星期四UTC+8下午8时58分40秒,Michael Bayer写道: > > when the DBAPI cursor has no .description object, it i

Re: [sqlalchemy] this result object does not return rows. it has been closed automatically

2014-03-27 Thread Ni Wesley
It's not happening everytime. And I am not using mysql-python, instead, I use pymysql. So, the root cause is connection in bad state? How to fix or work around from sqlalchemy side? Wesley 在 2014年3月27日星期四UTC+8下午8时58分40秒,Michael Bayer写道: > > when the DBAPI cursor has no .description object, it i

Re: [sqlalchemy] this result object does not return rows. it has been closed automatically

2014-03-27 Thread Michael Bayer
when the DBAPI cursor has no .description object, it is determined to not be a result-row returning object. The MySQLDB DBAPI has been observed to occasionally have issues in this area, when a connection gets into a bad state. There are likely patterns in how you're calling it that lead it to

Re: [sqlalchemy] Bulk Inserts and Unique Constraints

2014-03-27 Thread Michael Bayer
no DBAPI I've tested does it, at most it would only be possible for PG, SQL Server dialects. On Mar 27, 2014, at 2:30 AM, Cosmia Luna wrote: > Wow, I didn't know that... is it a bug? > > But, the RETURNING clause will work though :) > > stmt = P.__table__.insert(returning=[P.id], values=[{"va

[sqlalchemy] this result object does not return rows. it has been closed automatically

2014-03-27 Thread Ni Wesley
Hi all, Today I get an error as title. I use sqlalchemy + mysql. Here is my code snippet: def dbquery(_table,whereclause): try: #_table=Table(tablename, metadata, autoload=True) #_table = tables[tablename] i=_table.select().where(whereclause) if direct_e