Python Forum
sqlite3 table structure and db tables
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sqlite3 table structure and db tables
#2
"conn=" should return an error if the table does not exist. Note that both conn and c (cursor) are garbage collected when the function exits so return them if you want to use them elsewhere http://www.tutorialspoint.com/python/pyt...ctions.htm
To print the table structure use PRAGMA
import sqlite3 as sqlite

table_name="C:/Users/me/librarydb/booksdb"
con = sqlite.connect(table_name)
cur = con.cursor()

meta = cur.execute("PRAGMA table_info(%s)" % (table_name))
for r in meta:
    print(r) 
Reply


Messages In This Thread
RE: sqlite3 table structure and db tables - by woooee - May-15-2018, 06:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Using SQLAlchemy, prevent SQLite3 table update by multiple program instances Calab 3 821 Aug-09-2023, 05:51 PM
Last Post: Calab
  Slittping table into Multiple tables by rows drunkenneo 1 2,122 Oct-06-2021, 03:17 PM
Last Post: snippsat
  Yahoo_fin, Pandas: how to convert data table structure in csv file detlefschmitt 14 7,955 Feb-15-2021, 12:58 PM
Last Post: detlefschmitt
  Python script to summarize excel tables, then output a composite table? i'm a total n surfer349 1 2,429 Feb-05-2021, 04:37 PM
Last Post: nilamo
  Load data from One oracle Table to Multiple tables amy83 1 1,824 Dec-02-2020, 01:57 AM
Last Post: Larz60+
  Adding data to a table in SQLite3 djwilson0495 2 3,116 Aug-15-2020, 02:48 PM
Last Post: djwilson0495
  Creating a table in SQLite3 djwilson0495 2 2,120 Aug-10-2020, 03:01 PM
Last Post: djwilson0495
  How read Table Structure from Database nnsatpute 5 3,833 Oct-25-2019, 10:08 AM
Last Post: Larz60+
  Database table structure compare(Oracle) GKT 4 2,866 Oct-16-2019, 03:16 PM
Last Post: GKT
  sqlite3 db and table design pythonNoob 4 3,918 May-22-2018, 11:21 PM
Last Post: woooee

Forum Jump:

User Panel Messages

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