zjm1126 zjm1126 - 1 year ago 73
Python Question

How to create a new datebase(named xx.db) using python and sqlite3

import sqlite3

conn = sqlite3.connect(r"D:\aaa.db")

Is there a way to automatically create the db file if it doesn't already exist when I connect to it?


Answer Source

The code you give does create 'D:\\aaa.db' if it doesn't exist.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download