기본 콘텐츠로 건너뛰기

python sqlite3 db 생성하기

python-sqlite3.html

import sqlite3


# test db(file name)
# :memory: means RAM

db '''test_db'''


sql_t_person '''create table person (name text)'''


def main():


    con sqlite3.connect(db)


    con.isolation_level None # autocommit

    cur con.cursor()


    # create test_db

    cur.execute(sql_t_person)


    cur.close()

    return 0


if __name__ == '__main__'main()

댓글