Example #1
0
from db.litebase import liteBase, liteINTEGER, liteVARCHAR
from db.litebase import liteTable

if __name__ == '__main__':
		
	dstdb = liteBase('tatoeba.db')
	
	f = codecs.open("sentences.csv", "r", "utf-8")
	i = 0;
	for line in f:
		e = line.split("\t");
		if len(e) < 3:
			continue
		if e[1] in ("ara", "fra", "eng", "jpn"):
			if not dstdb.containsTable(e[1]):
				tab = liteTable()
				tab.beginTable(e[1])
				tab.addColumn('id', liteINTEGER(), u'', False)
				tab.addColumn('sent', liteVARCHAR(60), u'DEFAULT NULL', True)
				tab.endTable()
				dstdb.addTable(tab)
				#print tab.getSqlQuery()
			data = u'%s, "%s"' % (e[0],e[2])
			print data
			dst = dstdb.getTable(e[1])
			dst.insertData(data, u'id, sent')
			i = i + 1
			if (i>=1000):
				dstdb.commit() 
				i=0
	dstdb.commit() 
Example #2
0
#  

import sys
import os
import codecs
from db.litebase import liteBase, liteINTEGER, liteVARCHAR
from db.litebase import liteTable

if __name__ == '__main__':
	
	path = os.path.realpath("tatoeba.db")
	tatodb = liteBase(path)
	linksTable = liteTable()
	if not tatodb.containsTable("links"):
		linksTable.beginTable("links")
		linksTable.addColumn('jpnId', liteINTEGER(), u'', True)
		linksTable.addColumn('id', liteINTEGER(), u'', False)
		linksTable.endTable()
		tatodb.addTable(linksTable)
	else:
		linksTable = tatodb.getTable("links")
	
	f = codecs.open("links.csv", "r", "utf-8")
	lastskip = "0"

	jpnTable = tatodb.getTable('jpn')
	i = 0
	for line in f:
		e = line.split("\t");
		if len(e) < 2:
			continue