agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Bruce <okbishop@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: Problem with strange chars in text filed.
Date: Mon, 09 Jun 2014 16:06:46 -0700
Message-ID: <53963E06.70507@aklaver.com> (raw)
In-Reply-To: <CADzTWJnJ-sq9G56ev85q2NZAFVja8sZw645uxONPymqXO_EgBQ@mail.gmail.com>
References: <CADzTWJnJ-sq9G56ev85q2NZAFVja8sZw645uxONPymqXO_EgBQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

On 06/09/2014 09:02 AM, Bruce wrote:
> I have a table:
> create table truck (name varchar(45),address varchar(150));
>
> doing an insert:
> for i in range (0,10):
>      meme = fake.name <http://fake.name>()
>      address = fake.address()
>      print (meme,address)
>      cur.execute("INSERT INTO TRUCK2  VALUES (%s, %s)", ([meme], [address]))
>      conn.commit()

Assuming you are using psycopg2 the answer is here:

http://initd.org/psycopg/docs/usage.html#passing-parameters-to-sql-queries

so:

cur.execute("INSERT INTO TRUCK2  VALUES (%s, %s)", (meme, address))
or
cur.execute("INSERT INTO TRUCK2  VALUES (%s, %s)", [meme, address])

>
> Help
>


-- 
Adrian Klaver
adrian.klaver@aklaver.com


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (5+ messages)  latest in thread

Message-ID: <53963E06.70507@aklaver.com>
Permalink:  ../53963E06.70507@aklaver.com/
Also on:    postgresql.org/message-id/53963E06.70507@aklaver.com

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: adrian.klaver@aklaver.com, okbishop@gmail.com
  Subject: Re: Problem with strange chars in text filed.
  In-Reply-To: <53963E06.70507@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox