For example
conn = sqlite3.connect("test.db")
cursor = conn.cursor()
cursor.execute('CREATE TABLE IF NOT EXISTS TESTTABLE(ID INTEGER PRIMARY KEY AUTOINCREMENT,
NAME1 CHAR(5), NAME2 CHAR(5))')
conn.commit()
cursor.execute("INSERT INTO TESTTABLE(ID,NAME1,NAME2) VALUES(NULL',Hong Gil-dong,Kim Gap-hwan")")
conn.commit()
I made it roughly like this. The problem is that every time you run it, the insert statement is executed and the value continues to go in. How do I get this done only once when I run a program?
python sqlite3
Simply put, you only have to do it once (I'm not kidding.)
Single tone pattern can be used to make it called only once and init of the package.I think we can use py.
However, if you have the same concern as above, do not use the key as auto increment, but use the key as a unique value such as resident registration number or class number.
If the keys are the same, you can handle the exception.
581 PHP ssh2_scp_send fails to send files as intended
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
617 Uncaught (inpromise) Error on Electron: An object could not be cloned
912 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.