我有一個sqlite3數據庫有多個(六)表,我需要它被導入到csv,但是當我嘗試導入它時,如果一列(在表中)比另一個大在另一張桌子)。當使用python將sqlite3文件導出到csv時不會獲得重複值?
即:這是我的sqlite3的數據庫文件的樣子:
column on table1 column on table2 column on table3
25 30 20
30
這是對.csv文件的結果(使用this腳本爲例)
25,30,20
30,30,20
,這是結果我需要它顯示:
25,30,20
30
編輯:好的,這是我如何將值添加到每個表,ba sed的在python documentation example上(每次執行的值項用來):
import sqlite3
conn = sqlite3.connect('database.db')
c = conn.cursor()
# Create table
c.execute('''CREATE TABLE table
(column int)''')
# Insert a row of data
c.execute("INSERT INTO table VALUES (value)")
# Save (commit) the changes
conn.commit()
# We can also close the cursor if we are done with it
c.close()
任何幫助嗎?
-Regards ...
您需要向我們展示您的查詢,以便我們能夠爲您提供幫助。 –