Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41955 > unrolled thread
| Started by | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| First post | 2013-03-26 14:24 -0700 |
| Last post | 2013-03-27 19:17 -0700 |
| Articles | 18 on this page of 38 — 7 participants |
Back to article view | Back to comp.lang.python
MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-26 14:24 -0700
Re: MySQLdbd error. Perhpas it isn't installed? MRAB <python@mrabarnett.plus.com> - 2013-03-27 00:41 +0000
Re: MySQLdbd error. Perhpas it isn't installed? rurpy@yahoo.com - 2013-03-26 21:26 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-26 23:42 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 00:26 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 02:58 -0700
Re: MySQLdbd error. Perhpas it isn't installed? MRAB <python@mrabarnett.plus.com> - 2013-03-27 16:48 +0000
Re: MySQLdbd error. Perhpas it isn't installed? nagia.retsina@gmail.com - 2013-03-27 11:15 -0700
Re: MySQLdbd error. Perhpas it isn't installed? nagia.retsina@gmail.com - 2013-03-27 11:15 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 11:27 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 11:27 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 11:48 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Joel Goldstick <joel.goldstick@gmail.com> - 2013-03-27 15:06 -0400
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 12:13 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 12:13 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 12:23 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 12:23 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Chris Angelico <rosuav@gmail.com> - 2013-03-28 06:28 +1100
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 12:42 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 12:42 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 11:48 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-03-27 18:48 -0400
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:17 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:19 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:24 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Chris Angelico <rosuav@gmail.com> - 2013-03-28 13:33 +1100
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:36 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Chris Angelico <rosuav@gmail.com> - 2013-03-28 13:46 +1100
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:57 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:57 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 20:54 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Chris Angelico <rosuav@gmail.com> - 2013-03-28 14:57 +1100
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 20:54 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:36 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:24 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Chris Angelico <rosuav@gmail.com> - 2013-03-28 13:31 +1100
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:19 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:17 -0700
Page 2 of 2 — ← Prev page 1 [2]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 11:48 -0700 |
| Message-ID | <mailman.3818.1364410136.2939.python-list@python.org> |
| In reply to | #42025 |
I had encoding isseus as well! Now i tried your suggestion changing comma with '%' and now the error is more clear. [code] _mysql_exceptions.OperationalError: (1054, "Unknown column 'index.html' in 'where clause'") [/code] loook at http://superhost.gr please to see the whoel traceback
[toc] | [prev] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2013-03-27 18:48 -0400 |
| Message-ID | <mailman.3830.1364424563.2939.python-list@python.org> |
| In reply to | #41982 |
On Wed, 27 Mar 2013 16:48:44 +0000, MRAB <python@mrabarnett.plus.com>
declaimed the following in gmane.comp.python.general:
> A brief look at the documentation tells me that MySQL uses '?' as the
> placeholder instead of '%s':
>
> cur.execute('''SELECT hits FROM counters WHERE url = ?''', (page, ))
What documentation is that from... MySQLdb has used %s for ages (if
you look at the source code of the adapter, it actually uses Python's
string interpolation to fill in the SQL /after/ it has escaped/quoted
each parameter.
Now, I don't know about the recent "pure Python" MySQL adapter...
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 19:17 -0700 |
| Message-ID | <64b1d68a-7cc2-4039-b550-7f4970442aec@googlegroups.com> |
| In reply to | #42046 |
Τη Πέμπτη, 28 Μαρτίου 2013 12:48:54 π.μ. UTC+2, ο χρήστης Dennis Lee Bieber έγραψε:
> On Wed, 27 Mar 2013 16:48:44 +0000, MRAB <python@mrabarnett.plus.com>
>
> declaimed the following in gmane.comp.python.general:
>
>
>
>
>
> > A brief look at the documentation tells me that MySQL uses '?' as the
>
> > placeholder instead of '%s':
>
> >
>
> > cur.execute('''SELECT hits FROM counters WHERE url = ?''', (page, ))
>
>
>
> What documentation is that from... MySQLdb has used %s for ages (if
>
> you look at the source code of the adapter, it actually uses Python's
>
> string interpolation to fill in the SQL /after/ it has escaped/quoted
>
> each parameter.
>
>
>
> Now, I don't know about the recent "pure Python" MySQL adapter...
>
> --
>
> Wulfraed Dennis Lee Bieber AF6VN
>
> wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
So dod i have to use '%s' or (?) what is better? and as for the synatx that i asked in my previous post? what is the correct one?
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 19:19 -0700 |
| Message-ID | <bff5e093-fb67-4af7-ba83-725dcaec80bf@googlegroups.com> |
| In reply to | #42056 |
The following works in python 3.2
[code]
cur.execute( '''SELECT hits FROM counters WHERE url = ?''') , (page,)
[/code]
is there a difefrence between the above and the follwong which works in python 2.6
[code]
cur.execute( '''SELECT hits FROM counters WHERE url = ?''' , (page,) )
[/code]
Also whats better? use '%s' or '?' and why?
I'am confused. Which one is the correct?
Also now http://superhost.gr seems to stuck in the following line which i try to open an acii file to slect a random line, please take a look.
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 19:24 -0700 |
| Message-ID | <d3b24514-cf95-48c3-98da-c101c9240bae@googlegroups.com> |
| In reply to | #42057 |
I think i have figured this out:
cur.execute( '''SELECT hits FROM counters WHERE url = %s''') , (page,)
is a tuple of two objects. The first is the result of
cur.execute( '''SELECT hits FROM counters WHERE url = %s''')
and the second is
(page,)
cur.execute( '''SELECT hits FROM counters WHERE url = %s''' , (page,) )
is the result of the execute method of the cur object called with two arguments.
>>> int('10010110101', 2)
1205
>>> int('10010110101'), 2
(10010110101, 2)
>>>
Is this correct?
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-03-28 13:33 +1100 |
| Message-ID | <mailman.3839.1364438002.2939.python-list@python.org> |
| In reply to | #42060 |
On Thu, Mar 28, 2013 at 1:24 PM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote:
> I think i have figured this out:
>
> cur.execute( '''SELECT hits FROM counters WHERE url = %s''') , (page,)
>
> is a tuple of two objects. The first is the result of
> cur.execute( '''SELECT hits FROM counters WHERE url = %s''')
> and the second is
> (page,)
>
>
> cur.execute( '''SELECT hits FROM counters WHERE url = %s''' , (page,) )
> is the result of the execute method of the cur object called with two arguments.
>
>
>
>>>> int('10010110101', 2)
> 1205
>>>> int('10010110101'), 2
> (10010110101, 2)
>>>>
>
> Is this correct?
Ah, crossed in the post. Yes, this is correct, as you can confirm with
the operator precedence table that I posted above. (Experienced
programmers would have the universal precedences in their heads, but
the same applies.)
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 19:36 -0700 |
| Message-ID | <ece0d0fa-5568-4ffc-82dc-6e92ff92c603@googlegroups.com> |
| In reply to | #42065 |
Thank you for verifying this, Also now http://superhost.gr seems to stuck in the following line which i try to open an acii file to slect a random line, please take a look.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-03-28 13:46 +1100 |
| Message-ID | <mailman.3843.1364438811.2939.python-list@python.org> |
| In reply to | #42066 |
On Thu, Mar 28, 2013 at 1:36 PM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote: > Thank you for verifying this, > > Also now http://superhost.gr seems to stuck in the following line which i try to open an acii file to slect a random line, please take a look. Your quotes file isn't ASCII. Read the error message, Python is being very helpful. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 19:57 -0700 |
| Message-ID | <c5c06435-8eee-4701-91e9-b8baa95c1e3f@googlegroups.com> |
| In reply to | #42071 |
Τη Πέμπτη, 28 Μαρτίου 2013 4:46:48 π.μ. UTC+2, ο χρήστης Chris Angelico έγραψε: > On Thu, Mar 28, 2013 at 1:36 PM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote: > > > Thank you for verifying this, > > > > > > Also now http://superhost.gr seems to stuck in the following line which i try to open an acii file to slect a random line, please take a look. > > > > Your quotes file isn't ASCII. Read the error message, Python is being > > very helpful. Then how come the same .txt file opens normally in Python 2.6 i also tried to save ti as .ascii istead of utf-8 file and still same error also if i quote it out same things happen in those liens too. f = open( "/home/nikos/www/" + page ) htmldata = f.read() f.read produced the same kind of error. why?
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 19:57 -0700 |
| Message-ID | <mailman.3844.1364439452.2939.python-list@python.org> |
| In reply to | #42071 |
Τη Πέμπτη, 28 Μαρτίου 2013 4:46:48 π.μ. UTC+2, ο χρήστης Chris Angelico έγραψε: > On Thu, Mar 28, 2013 at 1:36 PM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote: > > > Thank you for verifying this, > > > > > > Also now http://superhost.gr seems to stuck in the following line which i try to open an acii file to slect a random line, please take a look. > > > > Your quotes file isn't ASCII. Read the error message, Python is being > > very helpful. Then how come the same .txt file opens normally in Python 2.6 i also tried to save ti as .ascii istead of utf-8 file and still same error also if i quote it out same things happen in those liens too. f = open( "/home/nikos/www/" + page ) htmldata = f.read() f.read produced the same kind of error. why?
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 20:54 -0700 |
| Message-ID | <07780f4e-62ec-430f-a0cf-fb551336ac18@googlegroups.com> |
| In reply to | #42074 |
this worked quote = random.choice( list( open( "/home/nikos/www/data/private/quotes.txt", 'rb') ) ) and also this f = open( "/home/nikos/www/" + page, 'rb' ) i dont know why python 3 needs 'rb' though. Now ima having problem with this: htmldata = htmldata % (quote, music) it says soemthign about wrong operand....
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-03-28 14:57 +1100 |
| Message-ID | <mailman.3848.1364443038.2939.python-list@python.org> |
| In reply to | #42080 |
On Thu, Mar 28, 2013 at 2:54 PM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote: > this worked > > quote = random.choice( list( open( "/home/nikos/www/data/private/quotes.txt", 'rb') ) ) > > and also this > > f = open( "/home/nikos/www/" + page, 'rb' ) > > i dont know why python 3 needs 'rb' though. > > Now ima having problem with this: > > htmldata = htmldata % (quote, music) > > it says soemthign about wrong operand.... http://www.joelonsoftware.com/articles/Unicode.html Read it. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 20:54 -0700 |
| Message-ID | <mailman.3847.1364442861.2939.python-list@python.org> |
| In reply to | #42074 |
this worked quote = random.choice( list( open( "/home/nikos/www/data/private/quotes.txt", 'rb') ) ) and also this f = open( "/home/nikos/www/" + page, 'rb' ) i dont know why python 3 needs 'rb' though. Now ima having problem with this: htmldata = htmldata % (quote, music) it says soemthign about wrong operand....
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 19:36 -0700 |
| Message-ID | <mailman.3840.1364438213.2939.python-list@python.org> |
| In reply to | #42065 |
Thank you for verifying this, Also now http://superhost.gr seems to stuck in the following line which i try to open an acii file to slect a random line, please take a look.
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 19:24 -0700 |
| Message-ID | <mailman.3835.1364437448.2939.python-list@python.org> |
| In reply to | #42057 |
I think i have figured this out:
cur.execute( '''SELECT hits FROM counters WHERE url = %s''') , (page,)
is a tuple of two objects. The first is the result of
cur.execute( '''SELECT hits FROM counters WHERE url = %s''')
and the second is
(page,)
cur.execute( '''SELECT hits FROM counters WHERE url = %s''' , (page,) )
is the result of the execute method of the cur object called with two arguments.
>>> int('10010110101', 2)
1205
>>> int('10010110101'), 2
(10010110101, 2)
>>>
Is this correct?
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-03-28 13:31 +1100 |
| Message-ID | <mailman.3838.1364437887.2939.python-list@python.org> |
| In reply to | #42057 |
On Thu, Mar 28, 2013 at 1:19 PM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote: > The following works in python 3.2 > > [code] > cur.execute( '''SELECT hits FROM counters WHERE url = ?''') , (page,) > [/code] This is an email list and newsgroup. You don't need tags like that. I don't know what you mean by "works". Check out the operator precedence table: http://docs.python.org/3.3/reference/expressions.html#operator-precedence Figure out what the above expression will do, then decide for yourself whether page is having any effect on it. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 19:19 -0700 |
| Message-ID | <mailman.3837.1364437811.2939.python-list@python.org> |
| In reply to | #42056 |
The following works in python 3.2
[code]
cur.execute( '''SELECT hits FROM counters WHERE url = ?''') , (page,)
[/code]
is there a difefrence between the above and the follwong which works in python 2.6
[code]
cur.execute( '''SELECT hits FROM counters WHERE url = ?''' , (page,) )
[/code]
Also whats better? use '%s' or '?' and why?
I'am confused. Which one is the correct?
Also now http://superhost.gr seems to stuck in the following line which i try to open an acii file to slect a random line, please take a look.
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 19:17 -0700 |
| Message-ID | <mailman.3834.1364437057.2939.python-list@python.org> |
| In reply to | #42046 |
Τη Πέμπτη, 28 Μαρτίου 2013 12:48:54 π.μ. UTC+2, ο χρήστης Dennis Lee Bieber έγραψε:
> On Wed, 27 Mar 2013 16:48:44 +0000, MRAB <python@mrabarnett.plus.com>
>
> declaimed the following in gmane.comp.python.general:
>
>
>
>
>
> > A brief look at the documentation tells me that MySQL uses '?' as the
>
> > placeholder instead of '%s':
>
> >
>
> > cur.execute('''SELECT hits FROM counters WHERE url = ?''', (page, ))
>
>
>
> What documentation is that from... MySQLdb has used %s for ages (if
>
> you look at the source code of the adapter, it actually uses Python's
>
> string interpolation to fill in the SQL /after/ it has escaped/quoted
>
> each parameter.
>
>
>
> Now, I don't know about the recent "pure Python" MySQL adapter...
>
> --
>
> Wulfraed Dennis Lee Bieber AF6VN
>
> wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
So dod i have to use '%s' or (?) what is better? and as for the synatx that i asked in my previous post? what is the correct one?
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.python
csiph-web