SQLite 3のテーブルに人のアカウントの詳細を格納するプログラムを作成する必要があります。カラムの1つは興味のあるものです。そのジャンルに基づいて映画の推薦をする必要があるので、そのジャンルの映画を保管する別のテーブルを用意する必要があります。唯一の問題は、テーブルをリンクする方法がわからないことです。コメディが好きなジャンルであれば、ジャンルコメディで映画を出力する方法です。あなたは1つのテーブル内のすべてのデータを保存しようとするべきではありませんPythonでSQLite 3のテーブルをリンクする
#function for creating a new customer's account
def create_id(username, password, name, address, DoB, gender, interestsUp, recent1, recent2, recent3, recent4, recent5, recent6, recent7, recent8, recent9, recent10):
#When adding something to a SQLite file, you have to put "" around each item
c.execute('INSERT INTO userId(username,password,name,address,DoB,gender,interests, recent1, recent2, recent3, recent4, recent5, recent6, recent7, recent8, recent9, recent10) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', (username, password, name, address, DoB, gender, interestsUp, recent1, recent2, recent3, recent4, recent5, recent6, recent7, recent8, recent9, recent10))#When adding something thats in a variable you put question marks and the name of the variables in brackets
conn.commit()
試した内容を示すコードを表示すると、より具体的な回答が得られる可能性があります。あなたはSQLに精通していますか?あなたは正しいアイデアを持っています - 映画タイトルを含む別のテーブルが良いです。おそらく、あなたの指示されたニーズに基づいてジャンルのための別のテーブルを持っている必要があります。だから、おそらく "映画"と "ジャンル"のテーブルがあります。そうすることで、たとえば、 "コメディ"と一致するジャンルのインデックスを "興味"の下のユーザーテーブルに保存することができます。また、 "films"テーブルにクエリして、ジャンル選択に合った映画のリストをユーザーに提供します。 –
@RonNorris私は外部キーを使用する必要があることを知っている、私はちょうどそれを作る方法を知らない。 –
あなたは参加が必要です - http://www.sqlitetutorial.net/sqlite-inner-join/ – Alan