Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8995391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:36:50+00:00 2026-06-15T23:36:50+00:00

I will post my code and explain after: db = sqlite3.connect(Gene.sqlite) cur = db.cursor()

  • 0

I will post my code and explain after:

db = sqlite3.connect("Gene.sqlite")
cur = db.cursor()
cur.execute("SELECT * FROM Table")
for i in cur.fetchall():
    if i[0] == name:
    print '<br>' '<c><b>TYPE'':</b>' ' '+ i[1]+ '<br>'\
    '<b>DESCRIPTION:</b></c>' ' '+ i[2]
    break
else:
    print 'This name does no exist in the Database'

This is in python and I am creating a CGI script where the user inputs a name, and my script goes into that database, searches for the name and prints out the row for that name. I have a database with a table called Table with thousands of names, I just want the user to input a name, and have it search through the table, and find one single name that matches the input, and if the name exists, print the necessary information (as shown). However, for every name that does not match, it prints This name does not exist until it finds a match, and if a match isn’t found, i just get thousands of messages saying “this name does not exist”. Basically, I want it to search the table without printing anything UNTIL it finds the name, and if it finds the name, prints out the information, and if it does not exist, just print once “This name does not exist int the database”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:36:51+00:00Added an answer on June 15, 2026 at 11:36 pm

    You need to use a WHERE clause:

    db = sqlite3.connect("Gene.sqlite")
    cur = db.cursor()
    looking_for = 'hello'
    cur.execute("SELECT type,description FROM Table WHERE name = '%s'", (looking_for,))
    for i in cur.fetchall():
        result = '<br><c><b>TYPE:</b> {}<br><b>DESCRIPTION:</b></c> {}'
        print result.format(*i)
    else:
        print '{} does not exist in the Database'.format(looking_for)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i will post my source code i have at the moment and explain my
I think the best way to explain this will be to post my code,
I will post my code below as a quick note I define both of
My code will process data in batches as recommended in this this post and
I don't know if I can explain this and post the proper code to
Guys i think im lost in my own code, I will try explain exactly
I will post two examples, one that validates and one that doesn't. I am
I need to write a script which will post username and password onto a
I have created a Webpage which will post as post method..not as get method.
Im trying to create a script that will post a notification stored in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.