agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedProblem with strange chars in text filed.
5+ messages / 3 participants
[nested] [flat]
* Problem with strange chars in text filed.
@ 2014-06-09 16:02 Bruce <okbishop@gmail.com>
2014-06-09 16:07 ` Re: Problem with strange chars in text filed. Rob Sargent <robjsargent@gmail.com>
2014-06-09 23:06 ` Re: Problem with strange chars in text filed. Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 2 replies; 5+ messages in thread
From: Bruce @ 2014-06-09 16:02 UTC (permalink / raw)
To: pgsql-sql
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()
address = fake.address()
print (meme,address)
cur.execute("INSERT INTO TRUCK2 VALUES (%s, %s)", ([meme], [address]))
conn.commit()
Heres what the data looks like:
xcv=# select * from truck2;
name | address
-----------------------+------------------------------------
{"Hana Mosciski"} | {"9597 Rosalia Rue +
| South Rossie, AS 22326"}
{"Paisley Miller"} | {"588 Lorin Vista +
| Merlinville, NY 79007"}
Whats up with the {" on each line.
Help
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Problem with strange chars in text filed.
2014-06-09 16:02 Problem with strange chars in text filed. Bruce <okbishop@gmail.com>
@ 2014-06-09 16:07 ` Rob Sargent <robjsargent@gmail.com>
2014-06-09 17:59 ` Fwd: Problem with strange chars in text filed. Bruce <okbishop@gmail.com>
1 sibling, 1 reply; 5+ messages in thread
From: Rob Sargent @ 2014-06-09 16:07 UTC (permalink / raw)
To: pgsql-sql
On 06/09/2014 10: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()
>
> Heres what the data looks like:
>
> xcv=# select * from truck2;
> name | address
> -----------------------+------------------------------------
> {"Hana Mosciski"} | {"9597 Rosalia Rue +
> | South Rossie, AS 22326"}
> {"Paisley Miller"} | {"588 Lorin Vista +
> | Merlinville, NY 79007"}
>
> Whats up with the {" on each line.
>
> Help
>
What's up with the '[' deref. in the execute?
^ permalink raw reply [nested|flat] 5+ messages in thread
* Fwd: Problem with strange chars in text filed.
2014-06-09 16:02 Problem with strange chars in text filed. Bruce <okbishop@gmail.com>
2014-06-09 16:07 ` Re: Problem with strange chars in text filed. Rob Sargent <robjsargent@gmail.com>
@ 2014-06-09 17:59 ` Bruce <okbishop@gmail.com>
0 siblings, 0 replies; 5+ messages in thread
From: Bruce @ 2014-06-09 17:59 UTC (permalink / raw)
To: pgsql-sql
That's probably it. Let me see if I can do the insert another way.
---------- Forwarded message ----------
From: Rob Sargent <robjsargent@gmail.com>
Date: Mon, Jun 9, 2014 at 12:02 PM
Subject: Re: [SQL] Problem with strange chars in text filed.
To: Bruce <okbishop@gmail.com>
Well {" is the array printing syntax for pg.
What language are you using? If it's python, it looks like you're making a
list/array with "[meme]"
Note. I top-posted here because this is off list. Best to stick with the
list so everyone is up-to-date, and there top-posting is frowned upon
(seriously so)
On 06/09/2014 10:57 AM, Bruce wrote:
That was in the example I had. Do you think it's what's causing the {" in
the table?
On Mon, Jun 9, 2014 at 11:07 AM, Rob Sargent <robjsargent@gmail.com> wrote:
> On 06/09/2014 10: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()
> address = fake.address()
> print (meme,address)
> cur.execute("INSERT INTO TRUCK2 VALUES (%s, %s)", ([meme], [address]))
> conn.commit()
>
> Heres what the data looks like:
>
> xcv=# select * from truck2;
> name | address
> -----------------------+------------------------------------
> {"Hana Mosciski"} | {"9597 Rosalia Rue +
> | South Rossie, AS 22326"}
> {"Paisley Miller"} | {"588 Lorin Vista +
> | Merlinville, NY 79007"}
>
> Whats up with the {" on each line.
>
> Help
>
> What's up with the '[' deref. in the execute?
>
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Problem with strange chars in text filed.
2014-06-09 16:02 Problem with strange chars in text filed. Bruce <okbishop@gmail.com>
@ 2014-06-09 23:06 ` Adrian Klaver <adrian.klaver@aklaver.com>
2014-06-10 01:44 ` Re: Problem with strange chars in text filed. Bruce <okbishop@gmail.com>
1 sibling, 1 reply; 5+ messages in thread
From: Adrian Klaver @ 2014-06-09 23:06 UTC (permalink / raw)
To: Bruce <okbishop@gmail.com>; pgsql-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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Problem with strange chars in text filed.
2014-06-09 16:02 Problem with strange chars in text filed. Bruce <okbishop@gmail.com>
2014-06-09 23:06 ` Re: Problem with strange chars in text filed. Adrian Klaver <adrian.klaver@aklaver.com>
@ 2014-06-10 01:44 ` Bruce <okbishop@gmail.com>
0 siblings, 0 replies; 5+ messages in thread
From: Bruce @ 2014-06-10 01:44 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: pgsql-sql
Thanks very much for the help. I am most great full.
Regards
On Mon, Jun 9, 2014 at 6:06 PM, Adrian Klaver <adrian.klaver@aklaver.com>
wrote:
> 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
>
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2014-06-10 01:44 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-06-09 16:02 Problem with strange chars in text filed. Bruce <okbishop@gmail.com>
2014-06-09 16:07 ` Rob Sargent <robjsargent@gmail.com>
2014-06-09 17:59 ` Bruce <okbishop@gmail.com>
2014-06-09 23:06 ` Adrian Klaver <adrian.klaver@aklaver.com>
2014-06-10 01:44 ` Bruce <okbishop@gmail.com>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox