简体   繁体   中英

joint two tables sqlite3

I am new to sqlite3, need your help to join these two table, I need to joint the team id between a coach and the teams table, but when compiling it tells me that there is a problem with teamID in the coach table. Any idea where is my mistake?

def creationTeamDB():
   with sqlite3.connect("teams.db") as db1:
   cursor = db1.cursor()

   cursor.execute('''
   CREATE TABLE IF NOT EXISTS team (
   teamID INTEGER PRIMARY KEY,
   teamName VARCHAR(20) NOT NULL
   )
   ''')

def creationCoachDB():
   with sqlite3.connect("coachs.db") as db2:
   cursor = db2.cursor()

   cursor.execute('''
   CREATE TABLE IF NOT EXISTS coach (
   coachID INTEGER PRIMARY KEY,
   coachName VARCHAR(20) NOT NULL
   teamID INTEGER
   )
   ''')

Thanks in advance, :) GB

You missed the comma in the second query

   CREATE TABLE IF NOT EXISTS coach (
   coachID INTEGER PRIMARY KEY,
   coachName VARCHAR(20) NOT NULL,
   teamID INTEGER
   )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM