Difference between revisions of "Python"

From truxwiki.com
Jump to navigation Jump to search
Line 45: Line 45:
 
=Classes=
 
=Classes=
 
Truxton exposes several classes to Python.
 
Truxton exposes several classes to Python.
* [[Python Top Level Object | Truxton]] - The top level object.
+
* [[TruxtonObject | Truxton]] - The top level object. The object responsible for a connection to Truxton.
 
* [[TruxtonArtifact]] - For adding records to the [[Entity Table | Entity table.]]
 
* [[TruxtonArtifact]] - For adding records to the [[Entity Table | Entity table.]]
 
* [[TruxtonChildFileIO]] - For writing a file to Truxton.
 
* [[TruxtonChildFileIO]] - For writing a file to Truxton.
Line 58: Line 58:
 
* [[TruxtonMedia]] - For adding media to Truxton.
 
* [[TruxtonMedia]] - For adding media to Truxton.
 
* [[TruxtonMessage]] - The way Truxton [https://en.wikipedia.org/wiki/Extract,_transform,_load ETL] processes communicate.
 
* [[TruxtonMessage]] - The way Truxton [https://en.wikipedia.org/wiki/Extract,_transform,_load ETL] processes communicate.
* [[TruxtonObject]] - The object responsible for a connection to Truxton.
 
 
* [[TruxtonRelation]] - For adding records to the [[Relation Table | Relation table]] for relating two items in Truxton.
 
* [[TruxtonRelation]] - For adding records to the [[Relation Table | Relation table]] for relating two items in Truxton.
 
* [[TruxtonUrl]] - For adding records to the [[WebsiteVisit Table | WebsiteVisit table.]]
 
* [[TruxtonUrl]] - For adding records to the [[WebsiteVisit Table | WebsiteVisit table.]]

Revision as of 13:00, 12 June 2020

Truxton supports Python 3.8 via the Truxton.pyd library.

You must use the "import" directive to load this. Got to the C:\Program Files\Truxton\SDK folder and start Python.

import truxton

When you import truxton you will get all of the predefined constants for file type, data type, origins, locations, messages, entities, relations, events, media, objects, url methods, and urls. You can see them all by issuing a dir command.

>>> dir(truxton)

This will allow your Python code to use the same constant names as C, C++ and C# code.

>>> print(truxton.Type_JPEG)
203

Once you have this working, you can start playing with Truxton.

import truxton

def main():
  t = truxton.create()
  print(t.version())

if __name__ == "__main__":
  main()

Style

In general, when using a Truxton API, you will follow this pattern:

  1. Create the object
  2. Set the data members of the object
  3. Call save() to store the object in the Truxton database.

Until you call save(), nothing will appear in Truxton.

Classes

Truxton exposes several classes to Python.

Remarks

The Python API is designed primarily for programs to contribute to Truxton.

Truxton.pyd was developed using the C API with a thin adapter layer of code to translate from Python provider semantics to Truxton calls.

Samples