Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a table in SQLite3
#1
I'm attempting to use the following piece of code to create a table in an SQLite3 database

cursor.execute("""CREATE TABLE IF NOT EXISTS Authors(Name text PRIMARY KEY, 
PlaceofBirth text NOT NULL,);""") # creates the Authors table with Name and PoB as fields
But I get this error:

Error:
File "c:/Users/djwil/Documents/python/learning python/Chapter 18 - SQLite/Ch18-c3.py", line 6, in <module> cursor.execute("""CREATE TABLE IF NOT EXISTS Authors(Name text PRIMARY KEY, sqlite3.OperationalError: near ")": syntax error
Can anyone offer any advice
Reply
#2
What is the trailing ',' for after "NOT NULL"?
Reply
#3
I got rid that and that solved the issue so thanks as lot :)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Using SQLAlchemy, prevent SQLite3 table update by multiple program instances Calab 3 703 Aug-09-2023, 05:51 PM
Last Post: Calab
  Creating table in MySQL db with decimal number issue dangermaus33 7 4,779 Nov-20-2020, 10:40 PM
Last Post: dangermaus33
  Adding data to a table in SQLite3 djwilson0495 2 3,001 Aug-15-2020, 02:48 PM
Last Post: djwilson0495
  Approach to creating Audit table pynewbie 4 3,747 Feb-24-2020, 06:12 PM
Last Post: pynewbie
  Creating a delimited file from DB Table anubhav2020 9 6,937 Sep-19-2018, 05:22 PM
Last Post: Axel_Erfurt
  Table creating code qqqqqqqqqqqq 1 2,440 Jun-18-2018, 11:15 AM
Last Post: gontajones
  Creating a table from a dataset anthonylauly 2 2,986 May-29-2018, 04:01 AM
Last Post: anthonylauly
  sqlite3 db and table design pythonNoob 4 3,727 May-22-2018, 11:21 PM
Last Post: woooee
  sqlite3 table structure and db tables pythonNoob 7 4,837 May-16-2018, 02:19 PM
Last Post: pythonNoob
  I need help creating tables with Sqlite3 Rius2 3 5,303 Sep-28-2017, 05:49 AM
Last Post: Rius2

Forum Jump:

User Panel Messages

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