· 9 years ago · Oct 20, 2016, 07:32 AM
1import sqlite3
2##import bcrypt
3
4##Function to create table
5def createtable( tname, id, songhash, hashtype, plays, playstype ):
6 db = sqlite3.connect('C:\\Users\\**private*\\python scripts\\songs.db')
7 c = db.cursor()
8
9
10 c.execute('CREATE TABLE IF NOT EXISTS {tn} ({nf} {ft} PRIMARY KEY'\
11 .format(tn=tname, nf=id, ft=type))
12
13 c.execute("ALTER TABLE {tn} ADD COLUMN IF NOT EXISTS '{cn}' {ct}"\
14 .format(tn=tname, cn=songhash, ct=hashtype))
15
16 c.execute("ALTER TABLE {tn} ADD COLUMN IF NOT EXISTS '{cn}' {ct}"\
17 .format(tn=tname, cn=plays, ct=playstype))
18
19 db.commit()
20 db.close()
21
22return
23
24haxchatcp = 'nowplaying'
25primary = 'primary'
26songhash = 'hash'
27hashtype = "CHAR(60)"
28plays = 'INTEGER'
29playstype = 'INTEGER'
30
31createtable( haxchatcp, primary, songhash , hashtype , plays, playstype )
32
33
34
35
36##current = open('C:\\Users\\InfraD3AD\\python scripts\\Tags.txt','r')
37##song = current.read()
38##name = "Winston_Smith"
39##message = '{0:<14} - is listening to: '.format(name)
40##playing = message+'{0: <14}'.format(song[3:])
41
42##print (playing)