0

My first SQL database Im using sqlite3 in idle on linux. Everything is working fine but I want my table to display in an easier to read format in the terminal. Been reading about dot commands eg .mode column or .headers on but not sure were to put it in my code, I think this is the closest:

def veiw_outstanding_job():
cursorObj = con.cursor()

cursorObj.execute('.mode column\nSELECT * FROM '+ VesselName + ' WHERE State = "outstanding" ')

rows = cursorObj.fetchall()

for row in rows:

    print(row)
menu()

but i get this error

Traceback (most recent call last):
  File "/usr/lib/python3.8/idlelib/run.py", line 559, in runcode
    exec(code,self.locals)
  File "/home/mike/Documents/Maintenance Manager/Maintenanceanager.py", line 238, in <module>
    menu()
  File "/home/mike/Documents/Maintenance Manager/Maintenance Manager.py", line 27, in menu
    veiw_job(con)
  File "/home/mike/Documents/Maintenance Manager/Maintenance Manager.py", line 54, in veiw_job
    cursorObj.execute('.mode column\nSELECT * FROM '+ VesselName) sqlite3.OperationalError: near ".":
syntax error

(also asked on database admin stackexchange and got sent here)

Terry Jan Reedy
  • 17,284
  • 1
  • 38
  • 50
dogfood
  • 3
  • 1
  • Does this answer your question? [Execute sqlite3 "dot" commands from Python or register collation in command line utility](https://stackoverflow.com/questions/2346074/execute-sqlite3-dot-commands-from-python-or-register-collation-in-command-line) – Nathan Furnal Dec 20 '21 at 14:26
  • Tracebacks should be formatted as if code to preserve line formatting. The code in your question is not what you ran as it has additional SyntaxErrors. – Terry Jan Reedy Dec 20 '21 at 19:20

0 Answers0