Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何确定arn';t使用自动增量_Python_Database_Sqlite_Identity - Fatal编程技术网

Python 如何确定arn';t使用自动增量

Python 如何确定arn';t使用自动增量,python,database,sqlite,identity,Python,Database,Sqlite,Identity,我已经创建了4个表,并使用ID将它们链接在一起。现在我如何确定使用什么作为ID 表格创建 import sqlite3 as lite queries = [] queries.append([''.join('CREATE TABLE Movie', '(id INTEGER PRIMARY KEY,', 'title INTEGER,', 'genre INTEGER,', 'cost INT

我已经创建了4个表,并使用ID将它们链接在一起。现在我如何确定使用什么作为ID

表格创建

import sqlite3 as lite

queries = []

queries.append([''.join('CREATE TABLE Movie',
            '(id INTEGER PRIMARY KEY,',
            'title INTEGER,',
            'genre INTEGER,',
            'cost INTEGER)')])

queries.append([''.join('CREATE TABLE Title',
            '(id INTEGER,',
            'English TEXT,',
            'Spansih TEXT,',
            'French TEXT)')])

queries.append([''.join('CREATE TABLE Genre',
            '(id INTEGER,',
            'Action INTEGER,',
            'Comedy INTEGER,',
            'Drama INTEGER',
            'Romance INTEGER)')])

queries.append([''.join('CREATE TABLE Cost',
            '(id INTEGER,',
            'Base INTEGER,',
            'Shipping INTEGER,',
            'Total INTEGER)')])
添加行

title_id = None # How do i determines these?
genre_id = None # Should I just use Integer Primary Key for each table id? 
cost_id = None # But then how do I get those id values to put into 



queries.append('''INSERT INTO Movies 
            (title, genre, cost) VALUES(%d, %d, %d)''' %
            (titile_id, genre_id, cost_id))

queries.append('''INSERT INTO Title
            (id, English) VALUES(%d, %s)''' %
            (title_id, 'Movie 1'))

queries.append('''INSERT INTO Genre
            (id, Action, Comedy) VALUES(%d, %d. %d)''' %
            (genre_id, 1, 1,))

queries.append('''INSERT INTO Cost
            (id, Base, Shipping, Total) VALUES(%d, %d, %d, %d)''' %
            (cost_id, 50, 8, 58))


for q in queries:
    print q
每个表的
id
应该是
INTEGER主键

title_id = None # How do i determines these?
cost_id = None # But then how do I get those id values to put into
在电影之前插入标题和成本。省略手动设置id(即,改为将do
插入成本(基本、装运、总计)值(…,…,…)
)。运行插入后,立即使用游标.lastrowid获取最新的自动生成id

title_id = None # How do i determines these?
cost_id = None # But then how do I get those id values to put into