def init(directory): """Initializes the MonetDBLite database in the specified directory.""" global MONETDBLITE_CURRENT_DATABASE global MONETDBLITE_IS_INITIALIZED if is_initialized(): raise exceptions.DatabaseError('Directory {} has already been initialized'.format(directory)) if directory == ':memory:': directory = None else: directory = utf8_encode(directory) retval = dll.python_monetdb_init(directory, 0) if retval is not None: raise __throw_exception(str(retval) + ' in ' + str(directory)) MONETDBLITE_IS_INITIALIZED = True MONETDBLITE_CURRENT_DATABASE = directory
def __throw_exception(str): raise exceptions.DatabaseError(str.replace('MALException:', ''))