Package bw :: Package poseidon :: Module poseidon :: Class Poseidon
[frames] | no frames]

Class Poseidon

object --+
         |
        Poseidon

Instance Methods
 
__init__(self, storages, name, inst)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
string or None
setContext(self, un, password)
Changes the security context of the database.
string
addContext(self, uuid, password, save=True)
Create/Modify a context for the given neuron.
boolean
removeContext(self, uuid, save=True)
Remove the context for the given id.
string
getDBName(self)
Returns the name of the database
number
findVerbCount(self, uuid)
Return the number of links in which uuid is the verb
number
findObjectCount(self, uuid)
Return the number of links in which uuid is the object
number
findSubjectCount(self, uuid)
Return the number of links in which l is the subject
string or None
authenticate(self, username, password)
Authenticate the username and password
dict
stats(self)
Return some statistics about the database
 
__destroy__(self)
 
__del__(self)
 
undump(self, fn)
INCOMPLETE: Undump the database from a file dumped by the dump method
string
dump(self, fn=None)
INCOMPLETE: Dump the database to a file fn.
boolean
pack(self)
Reorder and reorganize the data-files to save space.
string
isAlive(self)
Check if the RPC mechanism is working
boolean
close(self)
Safely close the database
string
addSnapshot(self, name=str(time.time()))
Create a snapshot called name
boolean
commit(self, Msg='', User='hk')
Commit changes made since the start of the transaction.
boolean
beginTransaction(self, c=thread.get_ident())
Start a new Transaction
boolean
rollback(self)
Abort current transaction and start a new one
list
checkAllCapabilities(self, resourceUUID)
Returns a list of capabilities that the actor for the current context has on the resource represented by resourceUUID.
 
checkCapability(self, v, o)
Returns True if we have the v capability for o.
dict
getCapability(self, s)
Returns a dictionary of capabilities for the actor s.
 
addCapability(self, s, v, o, save=True)
Give s the v capability on o if and only if the actor for the current context also has the capability.
 
removeCapability(self, s, v, o, save=True)
Revoke the v capability on o from s if and only if the actor for the current context also has the capability.
boolean
checkPolicy(self, v, o)
Return True if the actor for the current context has access for the v policy on resource o.
dict
getPolicy(self, o)
Returns the policy dictionary for the resource o.
 
setPolicy(self, o, v, policyString, save=False)
Set the v policy for resource o.
 
removePolicy(self, o, v=None, save=False)
Resets the v policy for the resource o to the default policy.
 
checkSecurity(self, v, o)
Check if the actor for the current context has access to o (either via capabilities or the policy for o).
 
process(self, v, nlist)
list
getLink(self, uuid, m, deleted=False)
Return a list of uuids of links where the neuron represented by uuid is participating as m.
boolean
validateName(self, x)
Return True if x is a valid name/alias for a meme.
Meme
addMeme(self, name, save=True)
Create a new meme with name name.
Dictionary (if key is None) or the type of the metadata value.
getMeta(self, uuid, key=None)
Gets the metadata dictionary for the neuron referenced by uuid.
string
setMeta(self, uuid, d, save=True)
Sets the metadata dictionary for a neuron referenced by uuid to the dictionary d.
boolean
removeMeta(self, uuid, key=None, save=False)
Removes metadata from the neuron referenced by uuid.
string
setBinary(self, uuid, data, save=True)
Add binary data contained in data to uuid.
string
getBinary(self, uuid)
Retrieve the file stored as binary data for meme uuid.
boolean
removeBinary(self, uuid, save=True)
Removes the binary data associated with the neuron referenced by uuid.
string or None
getIcon(self, uuid)
Returns the Icon data for the neuron referenced by uuid if it exists or None otherwise
string
setIcon(self, uuid, data, save=True)
Set the icon for u to be the data in data.
boolean
removeIcon(self, uuid, save=True)
Remove the icon for the neuron referenced by uuid.
list of strings
getIds(self, name)
Return all the uuids for a given name.
list
getNeuron(self, x)
Returns a list of neurons having the given name or uuid or list of names or ids.
string if uuid is a string, list if uuid is list of uuids
getName(self, uuid)
Return the name of the neuron with the given uuid.
list
getAlias(self, uuid, _flatten=True)
Returns a list of aliases for the neuron with the given uuid.
neurons.L
addLink(self, s, v, o, save=True)
Create a new link with subject s, verb v and object o.
boolean
isOrphan(self, uuid)
Returns True if the neuron referenced by uuid is not a member of any links.
boolean
removeLink(self, uuid, save=True)
Remove the link with the given uuid.
neurons.M
setName(self, uuid, name, save=True)
Rename the neuron with the given uuid to name.
The type of name (strings are assumed to be utf-8 and decoded to unicode) or list (if uuid is a list)
addAlias(self, uuid, name, save=True)
Add an alias name, to the neuron with the given uuid.
boolean
removeAlias(self, uuid, name, save=True)
Remove an the <name> alias to the neuron with the given uuid.
string
addView(self, uuid, q, columns=None, save=True)
Create a view based on the the query q
string
setView(self, uuid, q, new_name=None, new_columns=None, save=True)
Update the view with uuid to be based on the the query q
list or list of lists (if name is a list)
getView(self, name)
Return a list of dictionaries containing definitions for the view.
boolean
removeView(self, uuid, save=False)
Removes the view definitions associated with uuid
list
runView(self, uuid)
Run the view and return the results
list
query(self, q, notLinks=False, target=None)
Run a query on the database.
boolean
removeObject(self, uuid, save=True)
This method removes an object by removing the links to all its attributes.
string
addObject(self, obj, name=None, save=True)
Save the object obj to disk.
 
mergeObject(self, a, b)
string
setObject(self, uuid, obj, save=True)
Update the object referenced by uuid using the dictionary obj.
idea.Idea
getObject(self, uuid)
Returns the Idea object with the given uuid.
number
bulkInsert(self, filename, column_headers, typ=None, typ_verb=None, field_delimiter=",", enclosing_char='"', escape_char="\\", line_prefix="", line_delimiter="\r\n", ignore_lines=0)
Insert a csv file into the database.
 
graph(self)

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties

Inherited from object: __class__

Method Details

__init__(self, storages, name, inst)
(Constructor)

 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

setContext(self, un, password)

 

Changes the security context of the database.

The password is sha-1 hashed and checked against whatever is stored. To implement alternate algorithms, double hashing can be used where the first hash is whatever the client wants. This also eliminates the need to send the password in plaintext over the network.

Parameters:
  • un - The username of the user
  • password - The password of the user
Returns: string or None
The uuid of the actor meme of the new context or None on failure.

addContext(self, uuid, password, save=True)

 

Create/Modify a context for the given neuron.

Once a context has been created, it is possible to set the connection's context to that neuron and it's security settings are applied to the rest of the calls. The current context requires write permissions to the neuron represented by @uid to be able to create a context.

Parameters:
  • uuid - the 32 byte hex representation of the uuid of the neuron for which we want to create a context.
  • password - the password of the context. Existing passwords are modified
  • save - If save is true, then commit the transaction immediately. Default: True
Returns: string
The uuid of the neuron if successful.

removeContext(self, uuid, save=True)

 

Remove the context for the given id.

Parameters:
  • uuid - the 32 byte hex representation of the uuid or list of uuids of the neuron(s) whose context we wish to remove
  • save - Autocommit. Default: True
Returns: boolean
True on success.

getDBName(self)

 

Returns the name of the database

Returns: string
The name of the database

findVerbCount(self, uuid)

 

Return the number of links in which uuid is the verb

Parameters:
  • uuid (str or list) - A single or a list of the 32 byte hex representation of the uuid retrieved using get_id()
Returns: number
The number of links in which uuid is the verb

findObjectCount(self, uuid)

 

Return the number of links in which uuid is the object

Parameters:
  • uuid (str or list) - A single or a list of the 32 byte hex representation of the uuid retrieved using get_id()
Returns: number
The number of links in which uuid is the object

findSubjectCount(self, uuid)

 

Return the number of links in which l is the subject

Parameters:
  • uuid (str or list) - A single or a list of the 32 byte hex representation of the uuid retrieved using get_id()
Returns: number
The number of links in which uuid is the subject

authenticate(self, username, password)

 

Authenticate the username and password

Parameters:
  • username (str) - The username of the account
  • password (str) - The password for the account
Returns: string or None
None if authentication failed. Otherwise, returns the hex representation of the id of the account

stats(self)

 

Return some statistics about the database

Returns: dict
A dictionary containing "version" : Version Number "name" : The database name "inst" : The database instance id "ip" : The IP Address of the database server "host" : The hostname of the database server "os" : The O/S name of the server "port" : The port number on which the database is being served "start_time" : The timestamp at which the database server was started "query_count": The total number of queries run by this worker "qcache_hits": The number of hits in the client query cache [cache_efficiency = (qcache_hits/query_count)] "safe" : Boolean value denoting whether the database is currently locked or not "_storages" : Storage specific info. see ioengine.PersistenceEngine.stats

undump(self, fn)

 

INCOMPLETE: Undump the database from a file dumped by the dump method

Parameters:
  • fn - The filename to read from
Returns:
None

dump(self, fn=None)

 

INCOMPLETE: Dump the database to a file fn.

Parameters:
  • fn - The filename to dump to
Returns: string
The filename

pack(self)

 

Reorder and reorganize the data-files to save space. This method has no impact on future performance. However, it should only be run when there is little or no load.

Returns: boolean
True

isAlive(self)

 

Check if the RPC mechanism is working

Returns: string
The service name

close(self)

 

Safely close the database

Returns: boolean
True if the database was closed successfully

addSnapshot(self, name=str(time.time()))

 

Create a snapshot called name

Parameters:
  • name (string) - The name of the snapshot. Default: The current timestamp
Returns: string
The name of the snapshot

commit(self, Msg='', User='hk')

 

Commit changes made since the start of the transaction.

The parameters are ignored and are present for legacy compatibility.

Returns: boolean
True on success

beginTransaction(self, c=thread.get_ident())

 

Start a new Transaction

Transactions are separated by threads. At the end of the transaction, the thread is reused for the next transaction.

Since you cannot run a single transaction in multiple threads, the thread id is a good choice for the transaction id. However, the user is free to use any unique id naming scheme. Ordinarily, the default value should be good enough.

Parameters:
  • c - The id of the transaction. Default: the id of the thread.
Returns: boolean
True

rollback(self)

 

Abort current transaction and start a new one

Returns: boolean
True on success

checkAllCapabilities(self, resourceUUID)

 

Returns a list of capabilities that the actor for the current context has on the resource represented by resourceUUID.

Parameters:
  • resourceUUID (string) - The uuid of the resource neuron.
Returns: list
A list containing one or more of ['read', 'write', 'link']

checkCapability(self, v, o)

 

Returns True if we have the v capability for o.

To have the capability for a link, you must have that capability for its subject and object (but not necessarily its verb).

Parameters:
  • v - The capability we're checking for. One of ("read", "write", "link")
  • o - The uuid of the resource.
Returns:
True if we have the v capability for o. False otherwise.

getCapability(self, s)

 

Returns a dictionary of capabilities for the actor s.

Parameters:
  • s - The id of the actor or list of ids of actors whose capabilities we wish to retrieve.
Returns: dict
A dictionary containing three keys ("read", "write", "link") each value being a set of ids of resources.

addCapability(self, s, v, o, save=True)

 

Give s the v capability on o if and only if the actor for the current context also has the capability.

Parameters:
  • s - The id of the actor or list of ids of actors to who we're giving the capability
  • v - The capability we're giving. One of ('read', 'write', 'link')
  • o - The id of the resource for which we're giving the capability (must be a meme)
  • save - If save is true, then commit the transaction immediately. Default: True
Returns:
True if successful.

removeCapability(self, s, v, o, save=True)

 

Revoke the v capability on o from s if and only if the actor for the current context also has the capability.

Parameters:
  • s - The id of the actor from who we're revoking the capability
  • v - The capability we're revoking. One of ('read', 'write', 'link')
  • o - The resource for which we're revoking the capability (must be a meme)
  • save - If save is true, then commit the transaction immediately. Default: True
Returns:
True if successful.

checkPolicy(self, v, o)

 

Return True if the actor for the current context has access for the v policy on resource o.

Parameters:
  • v - The policy we're checking access for. One of ('read', 'write', 'link').
  • o - The id of the resource for which we're checking policies.
Returns: boolean
True if the actor for the current context has v policy access for o.

getPolicy(self, o)

 

Returns the policy dictionary for the resource o.

Parameters:
  • o - The id of the resource or list of ids of resources whose policies we want to get.
Returns: dict
A dictionary of policies contianing three keys ("read", "write", "link"). Each value is an evaluable string or list of evaluable strings.

setPolicy(self, o, v, policyString, save=False)

 

Set the v policy for resource o. The actor for the current context must have the v capability on o to be able to set the policy.

Parameters:
  • o - The id of the resource for which we are setting the policy
  • v - The name of the policy we are setting. One of ("read", "write", "link")
  • policyString (string) - An evaluateable expression.
  • save - If save is true, then commit the transaction immediately. Default: True
Returns:
The id of the resource whose policy was set

removePolicy(self, o, v=None, save=False)

 

Resets the v policy for the resource o to the default policy.

v is either ("read", "write", "link") or None. If v is None, then all the policies are reset

Parameters:
  • o - The uuid of the resource or list of resources whose policies are to be reset
  • v - None or the name of the policy to be reset. One of ("read", "write", "link"). Defaults to None
  • save - If save is true, then commit the transaction immediately. Default: True
Returns:
True if successful.

checkSecurity(self, v, o)

 

Check if the actor for the current context has access to o (either via capabilities or the policy for o). This is a convenience function which replaces self.checkCapability(v, o) or self.checkPolicy(v, o)

Parameters:
  • v - The name of the capability/policy to check for.
  • o - The id of the resource or a list of resource ids.
Returns:
True if either the capability or the policy checks out. False otherwise.

Like many other methods, this method accepts a single object o or a vector/sequence of objects. If the input is a sequence, the output is a list.

getLink(self, uuid, m, deleted=False)

 

Return a list of uuids of links where the neuron represented by uuid is participating as m.

Parameters:
  • uuid - The uuid of the neuron or list of uuids of the neurons which are participating as subject, verb or object.
  • m - One of "s", "v", "o" (for subject, verb, object)
  • deleted - Include uuids of deleted links in the result. Default: False
Returns: list
A list of uuids of links.

validateName(self, x)

 

Return True if x is a valid name/alias for a meme. Valid names are:

  1. String or Unicode which does not begin with '!' or '='
  2. One of the numeric types: (int, long, float)
  3. One of the immutable sequence types: (tuple, frozenset).
  4. A boolean
  5. None

Tuple/Frozenset contents are not indexed and therefore they cannot be retrieved except by exact match in getNeuron. They cannot be part of queries.

Parameters:
  • x - The candidate name/alias to validate.
Returns: boolean
True if x is valid. False otherwise.

addMeme(self, name, save=True)

 

Create a new meme with name name.

If another meme with the same name/alias exists, a duplicate one will be created. The developer is responsible for resolving such conflicts by first checking for the existence of a neuron with the same name via getNeuron. Your code should never call this method without first checking for existence via getNeuron.

The system administrator may also be required to resolve such conflicts in the following cases:

  1. If two neurons exist where one is a misspelt version of the other.
  2. If two neurons exist where one is a synonym of the other.
Parameters:
  • name - The name of the new meme
  • save - If save is True, commit the transaction immediately after creating the meme. Default: True
Returns: Meme
The new meme created

getMeta(self, uuid, key=None)

 

Gets the metadata dictionary for the neuron referenced by uuid. If key is provided, return the value for the specified key (or None if it does not exist).

Parameters:
  • uuid - The id of the meme or list of ids of the memes whose metadata is to be retrieved
  • key - Optional. The key of the specific metadata item to retrieve.
Returns: Dictionary (if key is None) or the type of the metadata value.
If key is not provided or is None, retrieve the entire metadata dictionary. Else retrieve the value of key

setMeta(self, uuid, d, save=True)

 

Sets the metadata dictionary for a neuron referenced by uuid to the dictionary d.

Parameters:
  • uuid - The id of the neuron whose metadata is to be updated.
  • d (dict) - A dictionary containing the new metadata.
Returns: string
The uuid of the neuron if the metadata was set correctly.

removeMeta(self, uuid, key=None, save=False)

 

Removes metadata from the neuron referenced by uuid.

Parameters:
  • uuid - The uuid of the neuron or list of ids of neurons whose metadata is to be removed.
  • key - If key is specified, then only that metadata key is removed. Otherwise everything is removed.
  • save - Optional. If save is True, commit the transaction immediately. Default: True.
Returns: boolean
True on success or False on error.

setBinary(self, uuid, data, save=True)

 

Add binary data contained in data to uuid.

The data is stored as a file on the filesystem. Metadata about the file its size and creation date are stored as key "com.brainwavelive.stat".

Parameters:
  • uuid - The uuid of the neuron.
  • data - An encoded string containing the binary data.
Returns: string
The uuid of the neuron for which the binary data was set.

getBinary(self, uuid)

 

Retrieve the file stored as binary data for meme uuid.

Parameters:
  • uuid - The uuid of the neuron or list of uuids of the neurons whose binary data is to be retrieved.
Returns: string
An encoded string containing all the data in the file or empty string on error.

removeBinary(self, uuid, save=True)

 

Removes the binary data associated with the neuron referenced by uuid.

This method does not support transactions

Parameters:
  • uuid - The uuid of the neuron or list of uuids of neurons whose binary data is to be removed
  • save - Autocommit. Default: True
Returns: boolean
True on success. False on error.

getIcon(self, uuid)

 

Returns the Icon data for the neuron referenced by uuid if it exists or None otherwise

Parameters:
  • uuid - The uuid of the neuron or list of uuids of neurons whose icon is to be retrieved.
Returns: string or None
A string of bytes containing the data or "" if it doesn't exist.

setIcon(self, uuid, data, save=True)

 

Set the icon for u to be the data in data.

This method does not support transactions and hence does not require a commit.

Parameters:
  • uuid - The id of the neuron for which the icon is to be set.
  • data - A string of bytes or a list of string of bytes containing the data for the icon. If data is None, the icon is removed.
Returns: string
The uuid of the neuron of which the icon was set.

removeIcon(self, uuid, save=True)

 

Remove the icon for the neuron referenced by uuid.

Parameters:
  • uuid - The id of the neuron or list of ids of neurons whose icon is to be removed.
  • save - Autocommit. Default: True.
Returns: boolean
True on success.

getIds(self, name)

 

Return all the uuids for a given name.

Parameters:
  • name - The name/alias or list of names/aliases to search for.
Returns: list of strings
A list of uuids of neurons having name as their name or alias.

getNeuron(self, x)

 

Returns a list of neurons having the given name or uuid or list of names or ids.

Parameters:
  • x - A name/alias or uuid.
Returns: list
A list of Neuron objects

getName(self, uuid)

 

Return the name of the neuron with the given uuid.

Parameters:
  • uuid - The uuid or list of uuids of the neuron(s)
Returns: string if uuid is a string, list if uuid is list of uuids
The name of the neuron or list of names of neurons.

getAlias(self, uuid, _flatten=True)

 

Returns a list of aliases for the neuron with the given uuid.

Parameters:
  • uuid - The uuid of the neuron
Returns: list
A list of aliases (string/tuple/boolean/number) of the given neuron. This list also contains the name of u. The name is nothing more than the default alias.

addLink(self, s, v, o, save=True)

 

Create a new link with subject s, verb v and object o.

Parameters:
  • s - The uuid of the subject of the new link
  • v - The uuid of the verb of the new link
  • o - The uuid of the object of the new link
  • save - If save is True, then immediately commit the transaction.
Returns: neurons.L
The new link instance.

isOrphan(self, uuid)

 

Returns True if the neuron referenced by uuid is not a member of any links.

Parameters:
  • uuid - The uuid of the neuron to test.
Returns: boolean
True if uuid is not a member of any links. False otherwise

removeLink(self, uuid, save=True)

 

Remove the link with the given uuid.

Removing links does not remove them from links in which they participate (so that total ressurection of links is possible); packing the database will remedy this.

Removing links also does not remove links in the subject/verb/object.

Parameters:
  • uuid - The uuid of the link or list of uuids of links to remove.
  • save - If save is True, the transaction is committed immediately afterwards. Default: True.
Returns: boolean
True if the link was successfully removed.

setName(self, uuid, name, save=True)

 

Rename the neuron with the given uuid to name.

Parameters:
  • uuid - The uuid of the neuron to rename
  • name - The new name.
Returns: neurons.M
The renamed neuron

Note: This method adds name as an alias of the neuron referenced by uuid. Other aliases are not modified. Hence, the old name of the neuron remains as an alias for the benefit of legacy code unless explictly removed via removeAlias

addAlias(self, uuid, name, save=True)

 

Add an alias name, to the neuron with the given uuid.

Parameters:
  • uuid - The uuid of the neuron or list of uuids of the neurons
  • name - The new alias to add
Returns: The type of name (strings are assumed to be utf-8 and decoded to unicode) or list (if uuid is a list)
The new alias if successful.

removeAlias(self, uuid, name, save=True)

 

Remove an the <name> alias to the neuron with the given uuid.

Parameters:
  • uuid - The uuid of the neuron or list of uuids of neurons
  • name - The alias to remove from the neuron (or each neuron if uuid is a list)
Returns: boolean
True if successful or False on error.

addView(self, uuid, q, columns=None, save=True)

 

Create a view based on the the query q

Parameters:
  • uuid - The uuid of the view
  • q - The query string
  • columns - A list of column names to return
  • save - Autocommit. Default: True.
Returns: string
The uuid of the view

setView(self, uuid, q, new_name=None, new_columns=None, save=True)

 

Update the view with uuid to be based on the the query q

Parameters:
  • uuid - The uuid of the view to update
  • q - The new query string
  • new_name - The new name of the query. Optional. Default: None means no change will be made
  • new_columns - A new list of column names to return. Default: No changes will be made
Returns: string
The uuid of the view updated

getView(self, name)

 

Return a list of dictionaries containing definitions for the view.

Each dictionary returned contains the following keys: ("_id", "_name", "_version", "_query", "_columns")

Parameters:
  • name - The name or uuid of a neuron referencing a view or list of names or uuids of neurons referencing views.
Returns: list or list of lists (if name is a list)
A list of results

removeView(self, uuid, save=False)

 

Removes the view definitions associated with uuid

Parameters:
  • uuid - the 32 byte hex representation of the uuid of the neuron containing the view you wish to remove.
  • save - If this is true, autocommit is enabled. Default: True.
Returns: boolean
True on success. False otherwise

runView(self, uuid)

 

Run the view and return the results

Parameters:
  • uuid - The name or uuid of the view
Returns: list
A list of results

query(self, q, notLinks=False, target=None)

 

Run a query on the database. The query is a string representing an advanced query.

Parameters:
  • q - The query string
  • notLinks - deprecated. This was part of the undocumented old-style queries which are still supported for legacy compatibility
  • target - deprecated. This was part of the undocumented old-style queries which are still supported for legacy compatibility
Returns: list
A list of results

removeObject(self, uuid, save=True)

 

This method removes an object by removing the links to all its attributes. It does not remove linked objects recursively.

Parameters:
  • uuid - A uuid or a list of uuids of objects which are to be removed.
  • save - If this is true, autocommit is enabled. Default: True.
Returns: boolean
True if all accessible attributes were removed. False otherwise

Note: UUIDs of objects are the same as the uuid of the subject neuron of the links representing the attributes of the object.

addObject(self, obj, name=None, save=True)

 

Save the object obj to disk. obj must be a dictionary like object. Its key-value pairs become the attributes and values of the new object.

Parameters:
  • obj - A dictionary like object which contains the attribute-value pairs
  • name - Optional. The name to save the object under. Default: Auto-generated
  • save - Optional. If this is True, autocommit is enabled. Default: True.
Returns: string
The uuid of the new object created.

setObject(self, uuid, obj, save=True)

 

Update the object referenced by uuid using the dictionary obj. Old attributes are not deleted since they may be in use by other applications.

Parameters:
  • uuid - The uuid of the object to modify
  • obj - The dictionary containing attribute-value pairs.
Returns: string
The uuid of the object modified.

getObject(self, uuid)

 

Returns the Idea object with the given uuid.

Parameters:
  • uuid - The name or uuid or list of names/uuids of the object(s) to retrieve
Returns: idea.Idea
The Idea instance or list of Idea instances.

bulkInsert(self, filename, column_headers, typ=None, typ_verb=None, field_delimiter=",", enclosing_char='"', escape_char="\\", line_prefix="", line_delimiter="\r\n", ignore_lines=0)

 

Insert a csv file into the database.

Parameters:
  • filename - The name of the file to import
  • column_headers - Must be a sequence of ids. No row can contain more fields than the number of column headers
  • typ - Optional. Must be the id of a neuron which is to be set as the type of each row.
  • typ_verb - Must be the id of a neuron which is to be used as the verb while setting the type (default = system.is_a)
  • field_delimiter - The string which is used to separate fields. Defaults to ",". This is passed as the field_delimiter attribute of the csv.Dialect object.
  • enclosing_char - The string which is used to enclose fields. Defaults to """. This is passed as the quotechar attribute of the csv.Dialect object.
  • escape_char - The string which is used to escape fields. Defaults to "\". This is passed as the escapechar attribute of the csv.Dialect object.
  • line_delimiter - This is ignored and assumed to be either \r, \n or \r\n (default = \r\n)
  • ignore_lines - The number of lines at the beginning of the file which are to be ignored. Defaults to 0.
  • line_prefix - Currently ignored (not implemented).
Returns: number
The number of rows imported