53 lines
1.2 KiB
Python
53 lines
1.2 KiB
Python
#! /usr/bin/python
|
|
|
|
# To change this template, choose Tools | Templates
|
|
# and open the template in the editor.
|
|
|
|
__author__="bjschuma"
|
|
__date__ ="$Jan 27, 2010 6:21:27 PM$"
|
|
|
|
|
|
from bt.message import write
|
|
from bt import sql
|
|
|
|
def init():
|
|
if sql.dbexists() == True:
|
|
return
|
|
|
|
table = sql.CTable("library")
|
|
table.addcol("id","INTEGER","PRIMARY KEY AUTOINCREMENT")
|
|
table.addcol("name","TEXT","UNIQUE")
|
|
table.addcol("path","TEXT","UNIQUE")
|
|
table.execute()
|
|
|
|
table = sql.CTable("artist")
|
|
table.addcol("id","INTEGER","PRIMARY KEY AUTOINCREMENT")
|
|
table.addcol("name","TEXT","UNIQUE")
|
|
table.execute()
|
|
|
|
table = sql.CTable("album")
|
|
table.addcol("id","INTEGER","PRIMARY KEY AUTOINCREMENT")
|
|
table.addcol("name","TEXT","UNIQUE")
|
|
table.execute()
|
|
|
|
table = sql.CTable("track")
|
|
table.addcol("id","INTEGER","PRIMARY KEY AUTOINCREMENT")
|
|
table.addcol("artist","INTEGER")
|
|
table.addcol("album","INTEGER")
|
|
table.addcol("count","INTEGER")
|
|
table.addcol("length","INTEGER")
|
|
table.addcol("name","TEXT")
|
|
table.addcol("path","TEXT","UNIQUE")
|
|
table.execute()
|
|
|
|
table = sql.CTable("libtrack")
|
|
table.addcol("library","INTEGER")
|
|
table.addcol("track","INTEGER")
|
|
table.execute()
|
|
|
|
|
|
|
|
def newlib(name,path):
|
|
ins = sql.Insert('library',[None,name,path])
|
|
ins.execute()
|
|
ins.commit() |