[Zope-DB] Help on uploading images to Postgresql

Charlie Clark charlie@begeistert.org
Sat, 05 Apr 2003 10:41:20 +0200


On 2003-04-05 at 05:05:58 [+0200], CY wrote:
>  Z SQL Method at  /STARS/Photo/uploadPhoto_sql  Help!
> --------------------------------------------------------------------------
>=20
> Error, psycopg.IntegrityError: ERROR: lo_import: can't open unix file=20
> "g:images=08irds.gif": No such file or directory insert into photo(=20
> person_id, comments, pic) values ('robert', 'happy bird day', lo_import=20
> ('g:\images\birds.gif') )
>=20
> --------------------------------------------------------------------------=
--
>=20
> SQL used:
>=20
> insert into photo(
>   person_id, comments, pic)
> values
>   ('robert',
>    'happy bird day',
>    lo_import ('g:\images\birds.gif')
>    )

I think the problem here is using "\" - why DOS uses "\" to separate paths=20
I don't know but it's not a good idea. In many prorgamming languages "\" is=20
a special character used to "escape" control characters like "\n" for=20
newline or "\t" for tab and as a result it needs to be "escaped" itself=20
when you use it, ie. "\\". So you write "g:\\images\\birds.gif. Luckily=20
Python os module allow the use of "/" for path separation and magically=20
transforms this to the appropriate character on the OS its's running on, so=20
you could also try "g:/images/birds.gif."

Hope that helps

Charlie