Python Forum
Need help with Return statement
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with Return statement
#9
I tried your suggestion but I am getting an SQLite3 operational error. Here is the code I tried.
import sqlite3

# Connect to the database
conn = sqlite3.connect('dinobase.db')

c = conn.cursor()

def getRecord(srchName, recNo, name, meaning, pronounce, period, group, size, lived, diet, fossils, factfile):
# Execute the query
    c.execute('SELECT recNo, name, meaning, pronounce, period, group, size, lived, diet, fossils, factfile FROM dino WHERE name = ?', (srchName,))

    # Retrieving data
    for row in c:
        recNo = row[0]
        name = row[1]
        meaning = row[2]
        pronounce = row[3]
        period = row[4]
        group = row[5]
        size = row[6]
        lived = row[7]
        diet = row[8]
        fossils = row[9]
        factfile = row[10]
        return c.fetchall()

# Close the connection
conn.close

srchName = "Dimetrodon"
recNo = 0
name = ""
meaning = ""
pronounce = ""
period = ""
group = ""
size = ""
lived = ""
diet = ""
fossils = ""
factfile = ""

recNo, name, meaning, pronounce, period, group, size, lived, diet, fossils, factfile = getRecord(srchName, recNo, name, meaning, pronounce, period, group, size, lived, diet, fossils, factfile)    #Call the search function

function_return = recNo, name, meaning, pronounce, period, group, size, lived, diet, fossils, factfile
print(recNo)
print("name : " + name)
print("meaning : " + meaning)
print("pronounce : " + pronouce)
print("period : " + period)
print("group : " + group)
print("size : " + size)
print("lived : " + lived)
print("diet : " + diet)
print("fossils : " + fossils)
print("\n")
print("factfile : " + factfile)
print("\n")
Yoriz write Sep-16-2022, 05:28 AM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Messages In This Thread
Need help with Return statement - by Columbo - Sep-15-2022, 04:19 PM
RE: Need help with Return statement - by Yoriz - Sep-15-2022, 04:33 PM
RE: Need help with Return statement - by Columbo - Sep-15-2022, 05:05 PM
RE: Need help with Return statement - by Yoriz - Sep-15-2022, 05:29 PM
RE: Need help with Return statement - by deanhystad - Sep-15-2022, 06:17 PM
RE: Need help with Return statement - by Columbo - Sep-15-2022, 07:40 PM
RE: Need help with Return statement - by Columbo - Sep-15-2022, 08:03 PM
RE: Need help with Return statement - by deanhystad - Sep-15-2022, 11:15 PM
RE: Need help with Return statement - by Columbo - Sep-16-2022, 01:26 AM
RE: Need help with Return statement - by deanhystad - Sep-16-2022, 02:31 AM
RE: Need help with Return statement - by Columbo - Sep-16-2022, 04:12 AM
RE: Need help with Return statement - by Pedroski55 - Sep-16-2022, 06:24 AM
RE: Need help with Return statement - by deanhystad - Sep-16-2022, 03:55 PM
RE: Need help with Return statement - by Columbo - Sep-17-2022, 04:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to invoke a function with return statement in list comprehension? maiya 4 4,065 Jul-17-2021, 04:30 PM
Last Post: maiya
  syntax error on return statement l_butler 5 4,221 May-31-2020, 02:26 PM
Last Post: pyzyx3qwerty
  return statement will not work TheTechRobo 2 3,332 Mar-30-2020, 06:22 PM
Last Post: TheTechRobo
  HELP! Return Statement Debugging HappyMan 5 4,281 Jan-27-2020, 07:31 PM
Last Post: michael1789
  Embedding return in a print statement Tapster 3 3,177 Oct-07-2019, 03:10 PM
Last Post: Tapster
  return statement usage SB_J 3 3,292 Jul-16-2019, 07:24 PM
Last Post: snippsat
  I don't understand this return statement 357mag 4 3,718 Jul-10-2019, 07:02 PM
Last Post: perfringo
  Return Statement in Python IDLE editor NMW 10 13,290 Jul-11-2017, 09:47 PM
Last Post: NMW
  Need help understanding return statement python_lover 4 5,383 Mar-03-2017, 10:09 AM
Last Post: python_lover
  Python basics about __init__ and return statement wk14 5 7,241 Oct-25-2016, 04:31 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020