def cities2table(filename, rel_name, dbname, verbose=False, setup=False):
 import sqlite3
 records = _str2records(filename, rel_name)
 connection = sqlite3.connect(dbname)
 cur = connection.cursor()
 if setup:
  cur.execute(u'CREATE TABLE city_table\n        (City text, Country text, Population int)')
 table_name = u'city_table'
 for t in records:
  cur.execute((u'insert into %s values (?,?,?)' % table_name), t)
  if verbose:
   print((u'inserting values into %s: ' % table_name), t)
 connection.commit()
 if verbose:
  print((u'Committing update to %s' % dbname))
 cur.close()

def cities2table ( filename , rel_name , dbname , verbose = False , setup = False ) : import sqlite3 records = _str2records ( filename , rel_name ) connection = sqlite3 . connect ( dbname ) cur = connection . cursor ( ) if setup : cur . execute ( u'CREATE TABLE city_table\n        (City text, Country text, Population int)' ) table_name = u'city_table' for t in records : cur . execute ( ( u'insert into %s values (?,?,?)' % table_name ) , t ) if verbose : print ( ( u'inserting values into %s: ' % table_name ) , t ) connection . commit ( ) if verbose : print ( ( u'Committing update to %s' % dbname ) ) cur . close ( )
convert a file of prolog clauses into a database table .