From: Thomas SMETS <tsmets@altern.org>
To: psql Admin <pgsql-admin@postgresql.org>
To: psql novice <pgsql-novice@postgresql.org>
To: psql sql <pgsql-sql@postgresql.org>
Subject: [Fwd: inserting integer in Table]
Date: Tue, 25 Jul 2000 04:02:36 +0200
Message-ID: <397CF53C.57790566@altern.org> (raw)
>
> In PostgreSQL table is :
> <snip>
> test=> \d test_blob_s;
> Table = test_blob_s
> +----------------------------------+----------------------------------+-------+
> | Field | Type |
> Length|
> +----------------------------------+----------------------------------+-------+
> | filenumber | int4
> | 4 |
> | filename | varchar()
> | 100 |
> | filecontent | oid
> | 4 |
> +----------------------------------+----------------------------------+-------+
> test=>
> </snip>
>
> Now I'm willing to insert in that table rows like this one :
> <i>, <file_name_i>, <file_name_i_content>.
>
> Here's is the (not-so-running) code :
>
> <snip>
> #
> #
> # ############################################
> import os, glob
> from pg import DB
>
> conn=DB('test')
> conn.query("BEGIN WORK;")
>
> i = 0
> for name in glob.glob("*.jpg"):
> print "Name is ", name,
> try:
> conn.query("insert into test_blob_s filenumber values (" + i +
> ")")
> print " inserted"
> except TypeError,e:
> print '\nerror ', e, 'undefined'
> # conn.query( "update test_blob_s set filename = '" + name + "')")
> # conn.query( "update test_blob_s set filecontent = '" +
> lo_import(name) + "')")
>
> i = i + 1
>
> conn.query(" COMMIT WORK;");
>
> </snip>
>
> of course I can't have it passing the insert of "i"
> Could some one help ?
>
> Thomas,
--
Thomas SMETS Phone : +32 (0)2 742. 05. 94.
Av. de la Brabançonne 133 / 3 e-mail : tsmets @altern.org
1030 Bruxelles
==== Quote of the day =========
You shouldn't wallow in self-pity. But it's OK to put your feet in it
and swish them around a little.
-- Guindon
======= End of Quote =========
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tsmets@altern.org, pgsql-admin@postgresql.org, pgsql-novice@postgresql.org
Subject: Re: [Fwd: inserting integer in Table]
In-Reply-To: <397CF53C.57790566@altern.org>
References: <397CF53C.57790566@altern.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox