Abandoned wrote:
> Also if i need a list id what can i do ?
>
> aia.execute("SELECT id, w from list")
> links=aia.fetchall()
>
> I want to..
>
> idlist=[1, 2, 3] ( I don't want to use FOR and APPEND because the
> query have 2 million result and i want to speed)
>
It may not be practical for you
Abandoned <[EMAIL PROTECTED]> wrote:
> ( I don't want to use FOR and APPEND because the
> query have 2 million result and i want to speed)
>
How many times do you plan on doing this? On my system I just timed adding
2 million elements to a dictionary: it took 0.35 seconds. Appending 2
million
On Mon, 2007-10-01 at 10:13 -0700, Abandoned wrote:
> Also if i need a list id what can i do ?
>
> aia.execute("SELECT id, w from list")
> links=aia.fetchall()
>
> I want to..
>
> idlist=[1, 2, 3] ( I don't want to use FOR and APPEND because the
> query have 2 million result and i want to speed)
Abandoned wrote:
> Also if i need a list id what can i do ?
>
> aia.execute("SELECT id, w from list")
> links=aia.fetchall()
>
> I want to..
>
> idlist=[1, 2, 3] ( I don't want to use FOR and APPEND because the
> query have 2 million result and i want to speed)
It will always return a list of
Also if i need a list id what can i do ?
aia.execute("SELECT id, w from list")
links=aia.fetchall()
I want to..
idlist=[1, 2, 3] ( I don't want to use FOR and APPEND because the
query have 2 million result and i want to speed)
--
http://mail.python.org/mailman/listinfo/python-list
On 1 Ekim, 18:13, Bruno Desthuilliers wrote:
> J. Clifford Dyer a écrit :
>
> > On Mon, Oct 01, 2007 at 03:50:59PM +0200, Bruno Desthuilliers wrote
> > regarding Re: Select as dictionary...:
> >> IIRC, postgres' db-api connector (well, at least one of them - I
J. Clifford Dyer a écrit :
> On Mon, Oct 01, 2007 at 03:50:59PM +0200, Bruno Desthuilliers wrote regarding
> Re: Select as dictionary...:
>> IIRC, postgres' db-api connector (well, at least one of them - I don't
>> know which one you're using) has a DictCursor.
On Mon, Oct 01, 2007 at 10:12:04AM -0400, Carsten Haese wrote regarding Re:
Select as dictionary...:
>
> On Mon, 2007-10-01 at 09:57 -0400, J. Clifford Dyer wrote:
> > >
> > Try this:
> >
> > aia.execute("SELECT id, w from list")
> > links=ai
> linkdict = dict(iter(aia.fetchone,None))
And by the way, that line can be shortened to "linkdict=dict(aia)" if
the cursor object supports the iterator protocol, but that's not a
mandatory feature in DB-API v2. The longer form is guaranteed to work
with any DB-API v2 compliant implementation.
--
On Mon, 2007-10-01 at 15:50 +0200, Bruno Desthuilliers wrote:
> Besturk.Net Admin a écrit :
> > I want to see this result directly as a dictionary:
> >
> > {1: 5, 2: 5 .}
> >
> > How do i select in this format ?
>
> IIRC, postgres' db-api connector (well, at least one of them - I don't
> kn
On Mon, Oct 01, 2007 at 03:50:59PM +0200, Bruno Desthuilliers wrote regarding
Re: Select as dictionary...:
>
> IIRC, postgres' db-api connector (well, at least one of them - I don't
> know which one you're using) has a DictCursor. You should find all you
> want
On Mon, 2007-10-01 at 09:57 -0400, J. Clifford Dyer wrote:
> On Mon, Oct 01, 2007 at 06:32:07AM -0700, Besturk.Net Admin wrote regarding
> Select as dictionary...:
> >
> > aia.execute("SELECT id, w from list")
> > links=aia.fetchall()
> > print lin
"J. Clifford Dyer" <[EMAIL PROTECTED]> wrote:
> aia.execute("SELECT id, w from list")
> links=aia.fetchall()
> linkdict = dict()
> for k,v in links:
> linkdict[k] = v
> print linkdict
Wouldn't it be simpler just to do:
aia.execute("SELECT id, w from list")
linkdict=dict(aia.fetchall())
On Mon, 01 Oct 2007 09:57:46 -0400, J. Clifford Dyer wrote:
> On Mon, Oct 01, 2007 at 06:32:07AM -0700, Besturk.Net Admin wrote
> regarding Select as dictionary...:
>>
>> aia.execute("SELECT id, w from list") links=aia.fetchall()
>> print links
>>
&g
> aia.execute("SELECT id, w from list")
> links=aia.fetchall()
> print links
>
> and result
> [(1, 5), (2,5)...] (2 million result)
>
> I want to see this result directly as a dictionary:
>
> {1: 5, 2: 5 .}
Because your fortuitously issued a select in that particular
order (key, value)
On 2007-10-01 15:32, Besturk.Net Admin wrote:
> Hi..
> I am using python with postgresql.
> And i have a query :
>
> aia.execute("SELECT id, w from list")
> links=aia.fetchall()
> print links
>
> and result
> [(1, 5), (2,5)...] (2 million result)
>
> I want to see this result directly as a d
On Mon, Oct 01, 2007 at 06:32:07AM -0700, Besturk.Net Admin wrote regarding
Select as dictionary...:
>
> aia.execute("SELECT id, w from list")
> links=aia.fetchall()
> print links
>
> and result
> [(1, 5), (2,5)...] (2 million result)
>
> I want to see
Besturk.Net Admin a écrit :
> Hi..
> I am using python with postgresql.
> And i have a query :
>
> aia.execute("SELECT id, w from list")
> links=aia.fetchall()
> print links
>
> and result
> [(1, 5), (2,5)...] (2 million result)
>
> I want to see this result directly as a dictionary:
>
> {1
Hi..
I am using python with postgresql.
And i have a query :
aia.execute("SELECT id, w from list")
links=aia.fetchall()
print links
and result
[(1, 5), (2,5)...] (2 million result)
I want to see this result directly as a dictionary:
{1: 5, 2: 5 .}
How do i select in this format ?
I'm
19 matches
Mail list logo