![]() |
2010-03-15
, 23:18
|
|
Posts: 1,648 |
Thanked: 2,122 times |
Joined on Mar 2007
@ UNKLE's Never Never Land
|
#11
|
![]() |
2010-03-17
, 09:00
|
Posts: 18 |
Thanked: 18 times |
Joined on Oct 2009
@ Barcelona, Spain
|
#12
|
import sqlite3 stationId = 0 def buildBlob(string): """ Builds the needed blob for value column """ return sqlite3.Binary(chr(1) + chr(0) * 3 + '@' + chr(0) * 3 + string + chr(0) ) def insertIntoDB(cursor, title, uri): """ inserts station in db""" global stationId stationId = stationId + 1 cursor.execute('INSERT INTO iradiobookmarks VALUES (?, "title", ?)', (stationId, buildBlob(title),)) cursor.execute('INSERT INTO iradiobookmarks VALUES (?, "mime-type", ?)', (stationId, buildBlob("audio"),)) cursor.execute('INSERT INTO iradiobookmarks VALUES (?, "uri", ?)', (stationId, buildBlob(uri),)) print 'inserted station %s' % title conn = sqlite3.connect("/home/user/.mafw.db") cursor = conn.cursor() cursor.execute('DELETE FROM iradiobookmarks') print 'database cleared' insertIntoDB(cursor, 'Radio 1', 'http://shoutcast.omroep.nl:8100/listen.pls') insertIntoDB(cursor, 'Radio 3', 'http://shoutcast.omroep.nl:8104/listen.pls') conn.commit() print 'commited!'
![]() |
2010-03-17
, 13:49
|
Posts: 6 |
Thanked: 11 times |
Joined on Mar 2010
@ NL
|
#13
|