[sqlalchemy] Question about sqlalchemy inserts and deletes order in a transaction
Hi, The code that I am working on deletes rows from table A that are based on a certain query and then recreates these rows based on entries supplied by a csv file. Table A is referenced by table B. My question is, how does sql alchemy manage inserts and deletes in a transaction and it what order are they done? It seems that deletes are done after inserts because I am getting unique constraint errors, although the rows are deleted before inserts are done. If my assumption is correct, how do I change this behaviour in SQLAlchemy. I do not want to add unique deferrable constraint into table A because its unique constraint key is being referred by table B, this is a limitation of postgres. Appreciate your feedback -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
RE: [sqlalchemy] Re: information about filed create_engine
> -Original Message- > From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] > On Behalf Of Eduardo > Sent: 18 July 2011 15:54 > To: sqlalchemy > Subject: [sqlalchemy] Re: information about filed create_engine > > Yes, I use wsgi server of the python library bottle and I don't have > any problem but when I want to use the same script via the apache web > server I get only a server error no exception could be caught not > even > by using the code snippet from you (Thanks by the way). I simply > included many print lines that appear in the error log file. The > create_engine fails (I know it from try and except) but I cannot > catch > any exception that sheds some light on the reason of the failure. > If you are getting a generic server error from Apache, you'll normally find the reason in the Apache error log (the location depends on your installation, but typically it is something like /var/log/httpd/error_log. Does that shed any light on the problem? Simon -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: information about filed create_engine
Yes, I use wsgi server of the python library bottle and I don't have any problem but when I want to use the same script via the apache web server I get only a server error no exception could be caught not even by using the code snippet from you (Thanks by the way). I simply included many print lines that appear in the error log file. The create_engine fails (I know it from try and except) but I cannot catch any exception that sheds some light on the reason of the failure. On Jul 18, 4:06 pm, "King Simon-NFHD78" wrote: > > -Original Message- > > From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] > > On Behalf Of Eduardo > > Sent: 18 July 2011 14:12 > > To: sqlalchemy > > Subject: [sqlalchemy] Re: information about filed create_engine > > > I dont get any log. The access strings from the local and wsgi > > applications are identical so the script should connect to the same > > database. I encountered problems with create_engine. What type of > > exception can this method throw? > > The application catches: TypeError, ValueError and OperationalError. > > Is there any other Error or some universal sqlalchemy error that can > > indicate me where the problem is? > > Thanks > > I'm sorry - I still don't understand your setup. How do you know that > you've "encountered problems with create_engine" if you're not getting > any kind of exception from it? > > If you really think that create_engine is failing but the exception is > being caught silently, why not change your code so that you've got an > exception handler around create_engine: > > try: > engine = create_engine(your_connection_string) > except Exception, e: > import traceback > log_file = open('/tmp/sqlalchemy_errors', 'w+') > log_file.write('Exception from create_engine\n') > log_file.write('%s\n' % e) > log_file.write(traceback.format_exc()) > raise > > But your life would be much easier if you learnt how to configure > SQLAlchemy's built-in logging features: > > http://www.sqlalchemy.org/docs/core/engines.html#configuring-logging > > What WSGI server and web framework are you using (if any)? It sounds > like they are hampering your efforts to debug this. You might find it > easier to run a very simple wsgi server such as the one in the wsgiref > module: > > http://docs.python.org/library/wsgiref.html#module-wsgiref.simple_server > > Simon -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
RE: [sqlalchemy] Re: information about filed create_engine
> -Original Message- > From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] > On Behalf Of Eduardo > Sent: 18 July 2011 14:12 > To: sqlalchemy > Subject: [sqlalchemy] Re: information about filed create_engine > > I dont get any log. The access strings from the local and wsgi > applications are identical so the script should connect to the same > database. I encountered problems with create_engine. What type of > exception can this method throw? > The application catches: TypeError, ValueError and OperationalError. > Is there any other Error or some universal sqlalchemy error that can > indicate me where the problem is? > Thanks > I'm sorry - I still don't understand your setup. How do you know that you've "encountered problems with create_engine" if you're not getting any kind of exception from it? If you really think that create_engine is failing but the exception is being caught silently, why not change your code so that you've got an exception handler around create_engine: try: engine = create_engine(your_connection_string) except Exception, e: import traceback log_file = open('/tmp/sqlalchemy_errors', 'w+') log_file.write('Exception from create_engine\n') log_file.write('%s\n' % e) log_file.write(traceback.format_exc()) raise But your life would be much easier if you learnt how to configure SQLAlchemy's built-in logging features: http://www.sqlalchemy.org/docs/core/engines.html#configuring-logging What WSGI server and web framework are you using (if any)? It sounds like they are hampering your efforts to debug this. You might find it easier to run a very simple wsgi server such as the one in the wsgiref module: http://docs.python.org/library/wsgiref.html#module-wsgiref.simple_server Simon -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: information about filed create_engine
I dont get any log. The access strings from the local and wsgi applications are identical so the script should connect to the same database. I encountered problems with create_engine. What type of exception can this method throw? The application catches: TypeError, ValueError and OperationalError. Is there any other Error or some universal sqlalchemy error that can indicate me where the problem is? Thanks On Jul 14, 3:43 pm, "King Simon-NFHD78" wrote: > Eduardo wrote: > > On Jul 14, 10:49 am, "King Simon-NFHD78" > > wrote: > > > Eduardo wrote > > > > > When I use the same script with a standalone application it works > > but > > > > when I try to run it as a wsgi application it fails (wsgi logs > > does > > > > not contain any information regarding the failure!) > > > > Try turning on SQL logging (either by passing echo='debug') to > > > create_engine, or by configuring the python logging package as > > described > > > onhttp://www.sqlalchemy.org/docs/core/engines.html#configuring- > > logging. > > > Then you should see the SQL being issued and the results coming > > back > > > from the database. > > > > How are you configuring transactions? Is it possible that the > > > transaction isn't being committed at the end of the web request, so > > any > > > changes you've made are being discarded? > > > > Simon > > > My application only queries the database there are no inputs and > > therefore no transactions involved. > > What was the result of turning on SQL logging? Are you sure you're even > pointing at the same database that you were when you ran the standalone > script? Try printing the value of session.bind.url (or including it in HTTP > response, if you don't have easy access to the stdout from your wsgi script) > > Simon -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] PickleType to use mediumblob
Hi I want PickleType to use mediumblob instead of blob. i am trying the following from sqlalchemy.databases.mysql import MSMediumBlob class MediumPickle(PickleType): impl = mysql.MSMediumBlob class Task(DeclarativeBase): __tablename__ = 'tasks' context = Column(MediumPickle) is this ok or are there any better way to do this? thnx in advnace -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.