How to create a new database using python and sqlite3

zjm1126 :
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?

Alex Martelli :

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Importing a CSV file into a sqlite3 database table using Python

how to open a new sqlite3 database using sqlite3.h and cgo?

Create new database in php with SQLite3

How to create a db file in sqlite3 using a schema file from within python

Using `executemany` to update entries in an existing SQLite3 database (using Python sqlite3)

How do I check if a SQLite3 database is connected in Python?

Create new Access database and tables using Python

sqlite3 create database with callback using Node

How Can I connect to Sqlite3 database over SSH using Python?

How to tell if a value exists in a sqlite3 database, python

Crystal sqlite3 create new database

Python Sqlite3 - Using f strings for update database function

How to create correlated tables in a genomic database SQLite3

How can I create a SQLite table using the sqlite3 Python library with parameterized placeholders?

How to create a SQLite3 database of variable name safely

How to store a 0.2 value in sqlite3 database using python

Python. How to convert a sqlite3 database into an Excel file

Determining if a username is in a SQLite3 database using Python

create a table if not exist in sqlite3 python using variable

How to display information from database sqlite3 using GUI Tkinter in Python in a specific format?

How do you make a database using sqlite3 in python

How to create sqlite3 database

How can I read what is in a database and checking if a certain string is in there? i am using python with sqlite3

How to create a new SQLite3 database using Ruby?

How to insert variable to database table sqlite3 - Python

How to share a :memory: database between different process in python using python sqlite3 package

How to insert datetime into sqlite3 database using Python?

Python sqlite3: how to check if connection is an in-memory database?

How to access attached database's tables using python's sqlite3?