70 lines
1.1 KiB
Python
70 lines
1.1 KiB
Python
# This is a simple test plugin, to make sure everything is working
|
|
|
|
__author__="bjschuma"
|
|
__date__ ="$Dec 27, 2009 9:58:50 PM$"
|
|
|
|
|
|
global name, app, type, path, opt
|
|
name = "database"
|
|
app = "ocarina"
|
|
type = "core"
|
|
path = ""
|
|
opt = []
|
|
|
|
|
|
import settings
|
|
from bt.file import *
|
|
|
|
import sqlite3
|
|
|
|
#global conn, c
|
|
#conn = None
|
|
#c = None
|
|
global db
|
|
global conn
|
|
db = None
|
|
conn = None
|
|
|
|
|
|
# Collect all information for what to insert
|
|
# Build into a large statement, then insert
|
|
# This will speed things up
|
|
# Reconnect to sqlite at every run, to avoid thread problems
|
|
|
|
|
|
def create():
|
|
global conn
|
|
conn.execute("create table files (path text)")
|
|
|
|
|
|
def open():
|
|
global db, conn
|
|
conn = sqlite3.connect(db)
|
|
conn.text_factory = str
|
|
|
|
|
|
def close():
|
|
global conn
|
|
conn.commit()
|
|
conn.close()
|
|
conn = None
|
|
|
|
|
|
def init():
|
|
global db
|
|
db = join(settings.get("ocarina"),"ocarina.db")
|
|
dbExists = checkPath(db)
|
|
open()
|
|
if dbExists == False:
|
|
create()
|
|
close()
|
|
|
|
|
|
def insert(file):
|
|
global conn
|
|
if conn == None:
|
|
open()
|
|
#c = conn.cursor()
|
|
t = (file,)
|
|
conn.execute('insert into files values(?)',t)
|
|
#c.close() |