Federico Di Gregorio | 1 Oct 2004 08:42
Favicon
Gravatar

Re: Porting psycopg2 to FreeBSD 5-CURRENT

On Thu, 2004-09-30 at 10:55 +0200, Valentino Volonghi wrote:
> Hi :), 
> I recently shifted from gentoo to FreeBSD and since I used psycopg2
> for testing it out and because it's a great piece of software I needed
> to build it on FreeBSD5 too.

thank you very much for this patch. are you sure that on freebsd5
postgresql is always in /usr/local? (or.. someone does know how to pass
*multiple* values in setup.cfg? <g>)

federico

--

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                fog@...
INIT.D Developer                                           fog@...
  We should forget about small efficiencies, say about 97% of the
   time: premature optimization is the root of all evil.    -- D.E.Knuth
_______________________________________________
Psycopg mailing list
Psycopg@...
http://lists.initd.org/mailman/listinfo/psycopg
Federico Di Gregorio | 2 Oct 2004 19:15
Favicon
Gravatar

RELEASE: psycopg 1.99.10

Hi everybody,

and especially all you building psycopg on *bsd. this new releases
should make better use of the setup.cfg configuration file (you can now
specify paths to postgresql header files and libpq in there) better
supporting compilation on non-linux architectures. many thanks go to
Terje Elde and Valentino Volonghi that helped me. (Valentino, your patch
will not be integrated, because you can now add the right configuration
options to setup.cfg.)

Please report and build problems and send me your setup.cfg files so
that I can include them as pre-cooked configurations in the next
release.

This release also features some other changes, detailed below. Download
from the usual ALPHA location or from subversion repository:

  http://initd.org/pub/software/psycopg/ALPHA/psycopg-1.99.10.tar.gz
  http://initd.org/svn/initd/psycopg2/tags/psycopg-1.99.10

What's new in psycopg 1.99.10
-----------------------------

* The adapt() function now fully supports the adaptation protocol
  described in PEP 246. Note that the adapters registry now is indexed
  by (type, protocol) and not by type alone. Change your adapters
  accordingly.

* More configuration options moved from setup.py to setup.cfg.

(Continue reading)

Terje Elde | 1 Oct 2004 15:15

Disable debug messages?

Hi,

Sorry if this is a silly question, but how do I disable the debug messages I'm
getting printed with psycopg2?

Terje
Terje Elde | 1 Oct 2004 13:20

Re: Porting psycopg2 to FreeBSD 5-CURRENT

On Fri, Oct 01, 2004 at 08:42:56AM +0200, Federico Di Gregorio wrote:
> > Hi :), 
> > I recently shifted from gentoo to FreeBSD and since I used psycopg2
> > for testing it out and because it's a great piece of software I needed
> > to build it on FreeBSD5 too.
> 
> thank you very much for this patch. are you sure that on freebsd5
> postgresql is always in /usr/local? (or.. someone does know how to pass
> *multiple* values in setup.cfg? <g>)

If the user does a manual install, or spesifically asks the port to install it
somewhere else, it might not be in /usr/local.

If the user installs as normal (using ports, and not forcing a different
installation dir), then it will always be in /usr/local.

Terje
Federico Di Gregorio | 3 Oct 2004 11:46
Favicon
Gravatar

Re: Disable debug messages?

On Fri, 2004-10-01 at 15:15 +0200, Terje Elde wrote:
> Hi,
> 
> Sorry if this is a silly question, but how do I disable the debug messages I'm
> getting printed with psycopg2?

just remove PSYCOPG_DEBUG from setup.cfg.

--

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                fog@...
INIT.D Developer                                           fog@...
           Se il sesso non ammacca \xC3\xA8 una patacca (!) -- Camilla Carotina
_______________________________________________
Psycopg mailing list
Psycopg@...
http://lists.initd.org/mailman/listinfo/psycopg
Pierre-Frédéric Caillaud | 3 Oct 2004 12:36

Re: psycopg client encoding to UNICODE


	something like :
	cursor.execute( 'SET client_encoding TO blah;' )

	?

> Hello
>
> I can;t seem to find any documentation or examples showing how to set the
> client encoding to UNICODE in  psycopg.
>
> A real world example would be magnificent.
>
> Apologies if this information is obviously available somewhere but I  
> can;t
> see it.
>
> Thanks
>
> Andrew Stuart
> a n d r e w . s t u a r t  <at>  x s e . c o m . a u
>
>
> _______________________________________________
> Psycopg mailing list
> Psycopg@...
> http://lists.initd.org/mailman/listinfo/psycopg
>
Matthias Teege | 3 Oct 2004 15:18
Picon

save images in the database

Moin,

I read the example from
http://www.free-soft.org/FSM/english/issue01/fog.html and try to save
an image in a postgresql table with the following code:

#!/usr/bin/env python
import sys, psycopg

DSN = 'dbname=db user=foo'
conn = psycopg.connect(DSN)

photo = open("/home/foo/pic/cblog.1.jpg").read()
data = {'img':psycopg.BINARY(photo),'obj':'3', 'ttl':'A first photo',
'typ':'Ansicht', 'dat':'~/pic/cblog.1.jpg'}

query  = "insert into objbild ( obj, ttl, typ, dat, img ) values ( "
query += "%(obj)s, %(ttl)s, %(typ)s, %(dat)s, %(img)s );"

curs = conn.cursor();
curs.execute(query, data)
conn.commit()

curs.execute('select img from objbild where obj = %s', ['3'])
data = curs.fetchone() 
open("foo.jpg", 'w').write(data[0]) 

I don't get any error but foo.jpg has only 4 bytes. How do I debug
this? Is it better to use large objects for images from 1k up to 20m?

(Continue reading)

Clinton Roy | 8 Oct 2004 07:28
Picon

quoting table names

Hello folks, 

I'm working on a system with dynamically created tables and columns
and such, so queries need to pass table names in and have them quoted
appropriately.

Unfortunately strings get quoted with single quotes, when table names
appear to need quoting with double quotes:

update 'type1' set 'int' = 3 where RecordId = 1

Am I going to have to do this myself, or is there something I'm missing?

ta folks,
--

-- 
Clinton Roy
www.humbug.org.au  - Brisbane Unix Group
staff.dstc.edu.au/croy - Blog
Clinton Roy | 8 Oct 2004 08:05
Picon

Re: quoting table names

Hi Jonathan,

On Fri, 08 Oct 2004 15:55:58 +1000, Jonathan Kelly
<jonkelly@...> wrote:
> Clinton Roy wrote:
> > Hello folks,
> >
> > I'm working on a system with dynamically created tables and columns
> > and such, so queries need to pass table names in and have them quoted
> > appropriately.
> >
> > Unfortunately strings get quoted with single quotes, when table names
> > appear to need quoting with double quotes:
> >
> > update 'type1' set 'int' = 3 where RecordId = 1
> >
> 
> You don't NEED to quote. If you do quote then the schema becomes case
> sensitive, and you have to use double-quotes, not single-quotes. Check
> the manual 4.1.1.

Sorry, I wasn't at all clear in my first email. My example was what
psycopg was creating, not what I wanted.

I'd very much like to use identifier quoting to preserve case and
spacing in table and column names.  At the moment, I can't see any way
of getting psycogp to do identifier quoting for me, and that's what
I'm after.

hopefully that's a bit clearer..
(Continue reading)

Daniele Varrazzo | 8 Oct 2004 09:37
Picon
Favicon

R: quoting table names

> I'm working on a system with dynamically created tables and columns
> and such, so queries need to pass table names in and have them quoted
> appropriately.
With psycopg2 is easy. Define a class for the schema names and create an
adapter for it.

class SchemaName(str):
    pass

psycopg.extensions.adapters[SchemaName] = \
	lambda s: '"%s"' % s.replace('"', '""')

sql = "INSERT INTO %(name)s VALUES (%(value)s);"
D =  {'name': SchemaName('stR"AN"ge name'), 'value': 'Goffredo'}

print cur.mogrify(sql, D)
INSERT INTO "stR""AN""ge name" VALUES ('Goffredo');

Gmane