Python Forum
Creating a table in SQLite3 - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Creating a table in SQLite3 (/thread-28934.html)



Creating a table in SQLite3 - djwilson0495 - Aug-10-2020

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


RE: Creating a table in SQLite3 - ndc85430 - Aug-10-2020

What is the trailing ',' for after "NOT NULL"?


RE: Creating a table in SQLite3 - djwilson0495 - Aug-10-2020

I got rid that and that solved the issue so thanks as lot :)