RE: [sqlalchemy] Re: information about filed create_engine

2011-07-19 Thread King Simon-NFHD78
Eduardo wrote:
> 
> /.../.../python2.6/site-packages/SQLAlchemy-0.6.5-
> py2.6.egg/sqlalchemy/
> dialects/postgresql/psycopg2.py", line 234, in dbapi
>  psycopg = __import__('psycopg2')
> ImportError: No module named psycopg2
> 
> The module psycopg2 is  already installed in the site-packages
> directory. I even included the path in the system variable by :
> sys.path.append('/.../.../python2.6/site-packages/') in the wsgi
> script.Still it won't work.
> Why?
> 

OK, this is definitely no longer an SQLAlchemy issue and more of a
mod_wsgi issue - you might get more help over on their mailing list
(http://code.google.com/p/modwsgi/wiki/WhereToGetHelp).

I believe psycopg2 is not a pure python module - it has a binary
component. Was it compiled with the same version of python that mod_wsgi
was?

Try this wsgi script (based on one from
http://code.google.com/p/modwsgi/wiki/InstallationIssues)

import sys
from pprint import pformat

def application(environ, start_response):
status = '200 OK'
output = ("sys.prefix: %r\nsys.path: %s\n"
  % (sys.prefix, pformat(sys.path))
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]

It would be worth comparing the output from that with the values of
sys.prefix and sys.path when run from bottle.

Hope that helps,

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

2011-07-19 Thread Eduardo
/.../.../python2.6/site-packages/SQLAlchemy-0.6.5-py2.6.egg/sqlalchemy/
dialects/postgresql/psycopg2.py", line 234, in dbapi
 psycopg = __import__('psycopg2')
ImportError: No module named psycopg2

The module psycopg2 is  already installed in the site-packages
directory. I even included the path in the system variable by :
sys.path.append('/.../.../python2.6/site-packages/') in the wsgi
script.Still it won't work.
Why?


On Jul 18, 5:23 pm, "King Simon-NFHD78"
 wrote:
> > -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.



RE: [sqlalchemy] Re: information about filed create_engine

2011-07-18 Thread King Simon-NFHD78
> -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

2011-07-18 Thread Eduardo
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

2011-07-18 Thread King Simon-NFHD78
> -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

2011-07-18 Thread Eduardo
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.



RE: [sqlalchemy] Re: information about filed create_engine

2011-07-14 Thread King Simon-NFHD78
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] Re: information about filed create_engine

2011-07-14 Thread Eduardo
My application only queries the database there are no inputs and
therefore no transactions involved.

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

-- 
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

2011-07-14 Thread King Simon-NFHD78
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
on http://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

-- 
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

2011-07-14 Thread King Simon-NFHD78
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
on http://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

-- 
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

2011-07-14 Thread King Simon-NFHD78
Eduardo wrote
> On Jul 13, 7:11 pm, "King Simon-NFHD78"
>  wrote:
> > Eduardo wrote
> >
> > > Hi,
> > > I am trying to prompt an answer from a database after failed
> > > create_engine command. I searched through the source code and I
> found
> > > TypeError, and ValueError returns but they relate (if I
> understood
> > > well only to the access parameters). My problem is that I am sure
> > > that
> > > my access parameters are correct but for some reason the creation
> of
> > > the engine fails. Is there any way to get information why the
> engin
> > > could not be created. The access to db log files is not granted!
> > > Thanks
> >
> > What kind of database are you trying to connect to? Are you getting
> a
> > Python exception, and if so, can you show us the traceback?
> >
> > Simon
> 
> !) PostgresSQL
> 2) I don't get any Python exception.
> 

So how do you know it's failing then?

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

2011-07-14 Thread Eduardo
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!)

On Jul 14, 10:16 am, "King Simon-NFHD78"
 wrote:
> Eduardo wrote
>
>
>
> > On Jul 13, 7:11 pm, "King Simon-NFHD78"
> >  wrote:
> > > Eduardo wrote
>
> > > > Hi,
> > > > I am trying to prompt an answer from a database after failed
> > > > create_engine command. I searched through the source code and I
> > found
> > > > TypeError, and ValueError returns but they relate (if I
> > understood
> > > > well only to the access parameters). My problem is that I am sure
> > > > that
> > > > my access parameters are correct but for some reason the creation
> > of
> > > > the engine fails. Is there any way to get information why the
> > engin
> > > > could not be created. The access to db log files is not granted!
> > > > Thanks
>
> > > What kind of database are you trying to connect to? Are you getting
> > a
> > > Python exception, and if so, can you show us the traceback?
>
> > > Simon
>
> > !) PostgresSQL
> > 2) I don't get any Python exception.
>
> So how do you know it's failing then?
>
> 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

2011-07-14 Thread Eduardo
!) PostgresSQL
2) I don't get any Python exception.

On Jul 13, 7:11 pm, "King Simon-NFHD78"
 wrote:
> Eduardo wrote
>
> > Hi,
> > I am trying to prompt an answer from a database after failed
> > create_engine command. I searched through the source code and I found
> > TypeError, and ValueError returns but they relate (if I understood
> > well only to the access parameters). My problem is that I am sure
> > that
> > my access parameters are correct but for some reason the creation of
> > the engine fails. Is there any way to get information why the engin
> > could not be created. The access to db log files is not granted!
> > Thanks
>
> What kind of database are you trying to connect to? Are you getting a
> Python exception, and if so, can you show us the traceback?
>
> 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.