Python Forum
how to use variables when open a sqlite database?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to use variables when open a sqlite database?
#1
this is my code

import sqlite3

conn = sqlite3.connect("KJV+.SQLite3")
c = conn.cursor()


while True:
    b_id = input('Enter the book id: ')
    c = input('Enter the chapter: ')
    p = input('Enter the position: ')
    c.execute("select * from verses where book_number = [b_id] and chapter = [c] and verse = [p]")
    text = c.fetchmany(1)
    print(text)
                      
    break
Yoriz write Apr-07-2022, 11:54 AM:
Reverted back to the previous edit that had code in it
Larz60+ write Apr-07-2022, 09:02 AM:
Please post all code, output and errors (it it's 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.
Fixed for you this time. Please use BBCode tags on future posts.
Reply
#2
Have you looked at the documentation? It does tell you how to parameterise a query.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  wrong entries in sqlite database and tkinter epsilondatum 2 427 Apr-23-2024, 04:48 PM
Last Post: epsilondatum
  Query in sqlite database frewil 2 1,614 Feb-06-2022, 05:35 PM
Last Post: frewil
  Python Variables and Sqlite3 Database Staples200 1 3,227 May-25-2021, 02:40 AM
Last Post: Staples200
  Importing data from a text file into an SQLite database with Python macieju1974 7 4,246 Jun-29-2020, 08:51 PM
Last Post: buran
  SQlite database portable? PythonWriter 1 2,554 Aug-11-2018, 02:39 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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