mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
Database() constructor works with pathlib.Path
This commit is contained in:
parent
3f2e711a4b
commit
57fc8ce55e
2 changed files with 12 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ import sqlite3
|
|||
from collections import namedtuple
|
||||
import datetime
|
||||
import json
|
||||
import pathlib
|
||||
|
||||
Column = namedtuple(
|
||||
"Column", ("cid", "name", "type", "notnull", "default_value", "is_pk")
|
||||
|
|
@ -16,6 +17,8 @@ class Database:
|
|||
def __init__(self, filename_or_conn):
|
||||
if isinstance(filename_or_conn, str):
|
||||
self.conn = sqlite3.connect(filename_or_conn)
|
||||
elif isinstance(filename_or_conn, pathlib.Path):
|
||||
self.conn = sqlite3.connect(str(filename_or_conn))
|
||||
else:
|
||||
self.conn = filename_or_conn
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue