For python 2.5 you need at least:
bz2.pyd
library.zip
MSVCR71.dll
psycopg2._psycopg.pyd
python25.dll
test.exe
unicodedata.pyd
w9xpopen.exe
NOTE the psycopg2._psycopg.pyd binary dll
Also, MSVCR71.dll surely will change for other versions of python, and
you'll be need manifests and/or other runtime files in order to load
the Visual C runtime (they should be already provided with the binary
web2py distribution).
In library.zip, you'll need at least the psycopg2 folder, with a bunch
of the stdlib
Attached is an example to gather this files, you can download from
http://www.sistemasagiles.com.ar/soft/psycopg2_py25_dist.zip
You can generate it with:
python setup.py py2exe
Then test it with
test.exe "dbname=postgres user=reingart password=secret
host=localhost" "SELECT generate_series(1,10)"
Best regards,
Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com
On Wed, Jan 11, 2012 at 12:53 PM, Alexandre Andrade
<alexandrema...@gmail.com> wrote:
> I remember the postgresql driver usually works with the source distribuition
> of web2py on windows.
>
> I think a way u get it working is use the source web2py on windows, and use
> py2exe or similar to create a executable.
>
>
> Alexandre Andrade
>
> 2012/1/10 Álvaro J. Iradier <airad...@gmail.com>
>
>> Hi,
>>
>> I was trying to distribute an application with web2py binary for
>> windows, but I required the PostgreSQL driver. So I copied the
>> psycopg2 files to site-packages in the web2py binary folder.
>>
>> If I start a shell from an application, I can import psycopg2 and
>> connect to the database. However, it looks like the DAL does not
>> recognize the psycopg2 driver. I am getting the error:
>>
>>
>> Traceback (most recent call last):
>> File "gluon/restricted.py", line 204, in restricted
>> File "C:/Users/airadier/Downloads/web2py_win/web2py/applications/
>> init/models/10_db.py", line 13, in <module>
>> File "gluon/dal.py", line 4749, in __init__
>> RuntimeError: Failure to connect, tried 5 times:
>> Traceback (most recent call last):
>> File "gluon/dal.py", line 4736, in __init__
>> File "gluon/dal.py", line 1867, in __init__
>> RuntimeError: Unable to import driver
>>
>> My guess is when DAL is being initialized, the site-packages folder is
>> not yet in the sys.path, so the following fails:
>>
>> try:
>> import psycopg2
>> from psycopg2.extensions import adapt as psycopg2_adapt
>> drivers.append('PostgreSQL')
>> except ImportError:
>> logger.debug('no psycopg2 driver')
>>
>> Is there a reason for this? Is it a bug or a feature?
>>
>> Is there other way to acomplish these? And is it allowed to distribute
>> a binary web2py including the PostgreSQL driver?
>>
>> Thanks in advance.
>
>
>
>
> --
> Atenciosamente
>
>
> Alexandre Andrade
> Hipercenter.com Classificados Gratuitos
import psycopg2
import sys
print "connecting to ", sys.argv[1]
conn = psycopg2.connect(sys.argv[1])
cur = conn.cursor()
print "executing", sys.argv[2]
cur.execute(sys.argv[2])
for row in cur:
print row
# Para hacer el ejecutable:
# python setup.py py2exe
#
"Creador de instalador para PyAfipWs"
__author__ = "Mariano Reingart (mari...@nsis.com.ar)"
__copyright__ = "Copyright (C) 2008 Mariano Reingart"
from distutils.core import setup
import py2exe
import sys
opts = {
'py2exe': {
'includes': [],
'optimize':2}
}
setup( name = "psycopg2 test",
console=['test.py'],
options=opts,
)