Re: [Tutor] Searching for email id in MySQL giving wrong results

2006-01-29 Thread Alan Gauld
> I am trying to search and display the results , even > if we give a part of the email_id >entry.execute("""SELECT * FROM contact WHERE > email_id = %s """, (s_email,)) If you want to do partial matches you will need to use LIKE ''' SELECT * FROM contact WHERE email_id LIKE %s '

Re: [Tutor] Searching for email id in MySQL giving wrong results

2006-01-29 Thread John Joseph
--- Danny Yoo <[EMAIL PROTECTED]> wrote: > > the email id which starts with “j” is > > select * from contact where email_id like 'j%'; > > Hi John, > > Ok, looks good so far. So in a Python program, we > might try something > like this: > > ##

Re: [Tutor] Searching for email id in MySQL giving wrong results

2006-01-29 Thread Danny Yoo
> the email id which starts with “j” is > select * from contact where email_id like 'j%'; Hi John, Ok, looks good so far. So in a Python program, we might try something like this: ## ## assuming cursor is set u

Re: [Tutor] Searching for email id in MySQL giving wrong results

2006-01-29 Thread John Joseph
--- Danny Yoo <[EMAIL PROTECTED]> wrote: > > Hi John, > > Ok; because the question you're asking looks a > little homework-y, we have > to be a little bit more cautious in our answers. > What part are you > getting stuck on? > > > Do you understand how SQL wildcards work? There's a > good n

Re: [Tutor] Searching for email id in MySQL giving wrong results

2006-01-29 Thread Danny Yoo
On Sun, 29 Jan 2006, John Joseph wrote: >I am sending the code of the function "searchbyemail" and the output >of the program when I run I am trying to search and display the >results , even if we give a part of the email_id Hi John, Ok; because the question you're asking looks a l

Re: [Tutor] Searching for email id in MySQL giving wrong results

2006-01-28 Thread John Joseph
Hi I am sending the code of the function "searchbyemail" and the output of the program when I run I am trying to search and display the results , even if we give a part of the email_id thanks Joseph John SEARCH by email _id functi

Re: [Tutor] Searching for email id in MySQL giving wrong results

2006-01-24 Thread Kent Johnson
John Joseph wrote: > Hi >Thanks to Allan,Danny,Pujo >I did my simple python script for MySQL , the > scripts add the data , and search for the data and > display > I have problem in searching email id ,ie > If search for the [EMAIL PROTECTED] , I will not get any > r

Re: [Tutor] Searching for email id in MySQL giving wrong results

2006-01-23 Thread Alan Gauld
Hi Ziyad, Don't beat yourself up over this, you were trying to be helpful and that's a good thing. The original syntax looked weird to me too, but mainly because the variable was inside a pair of parens, but because I didn't know MySql I didn't say anything at the time. But your answer seemed rea

Re: [Tutor] Searching for email id in MySQL giving wrong results

2006-01-23 Thread ZIYAD A. M. AL-BATLY
On Mon, 2006-01-23 at 14:00 -0500, Python wrote: > The wrong_string line was lifted from the following code in the OP. > > entry = db.cursor() > entry.execute("""SELECT * FROM contact WHERE email_id = %s""", > (s_email,)) > > The execute method will handle the string substitution

Re: [Tutor] Searching for email id in MySQL giving wrong results

2006-01-23 Thread Python
On Mon, 2006-01-23 at 19:46 +, Alan Gauld wrote: > >> >> wrong_string = '''SELECT s FROM t WHERE id=%s''' , (email_id) > >> > > >> The OP must replace the comma with a % character for the string > >> substitution to take place. > > > > The wrong_string line was lifted from the following

Re: [Tutor] Searching for email id in MySQL giving wrong results

2006-01-23 Thread Alan Gauld
>> >> wrong_string = '''SELECT s FROM t WHERE id=%s''' , (email_id) >> > >> The OP must replace the comma with a % character for the string >> substitution to take place. > > The wrong_string line was lifted from the following code in the OP. > >entry = db.cursor() >entry.ex

Re: [Tutor] Searching for email id in MySQL giving wrong results

2006-01-23 Thread Python
On Mon, 2006-01-23 at 18:17 +, Alan Gauld wrote: > > On Sun, 2006-01-22 at 21:23 +0300, ZIYAD A. M. AL-BATLY wrote: > >> wrong_string = '''SELECT s FROM t WHERE id=%s''' , (email_id) > > > > The string is being used in a call to cursor.execute. The email_id is a > > second parameter g

Re: [Tutor] Searching for email id in MySQL giving wrong results

2006-01-23 Thread Python
On Mon, 2006-01-23 at 18:17 +, Alan Gauld wrote: > > On Sun, 2006-01-22 at 21:23 +0300, ZIYAD A. M. AL-BATLY wrote: > >> wrong_string = '''SELECT s FROM t WHERE id=%s''' , (email_id) > > > > The string is being used in a call to cursor.execute. The email_id is a > > second parameter g

Re: [Tutor] Searching for email id in MySQL giving wrong results

2006-01-23 Thread Alan Gauld
> On Sun, 2006-01-22 at 21:23 +0300, ZIYAD A. M. AL-BATLY wrote: >> wrong_string = '''SELECT s FROM t WHERE id=%s''' , (email_id) > > The string is being used in a call to cursor.execute. The email_id is a > second parameter getting passed to execute. That is the *correct* > approach to

Re: [Tutor] Searching for email id in MySQL giving wrong results

2006-01-23 Thread Python
On Sun, 2006-01-22 at 21:23 +0300, ZIYAD A. M. AL-BATLY wrote: > wrong_string = '''SELECT s FROM t WHERE id=%s''' , (email_id) The string is being used in a call to cursor.execute. The email_id is a second parameter getting passed to execute. That is the *correct* approach to use. That

Re: [Tutor] Searching for email id in MySQL giving wrong results [ Try out pattern Search ]

2006-01-23 Thread John Joseph
Hi Thanks for the tip now I am trying to do pattern matching for MySQL , but I am not getting the result on MySQL , to select for all email starting with jos we do select * from contact where email_id like "jos%"; but I get confused how to use it , while executing it in python , how to

Re: [Tutor] Searching for email id in MySQL giving wrong results

2006-01-22 Thread ZIYAD A. M. AL-BATLY
On Sun, 2006-01-22 at 12:43 +, John Joseph wrote: > Hi Hi John... Most of your problems in your code seems to be caused by a single mistake. Compare the following two strings and you should figure out what's wrong by yourself: email_id = '[EMAIL PROTECTED]' wrong_s

[Tutor] Searching for email id in MySQL giving wrong results

2006-01-22 Thread John Joseph
Hi Thanks to Allan,Danny,Pujo I did my simple python script for MySQL , the scripts add the data , and search for the data and display I have problem in searching email id ,ie If search for the [EMAIL PROTECTED] , I will not get any result , Guidance and advice needed