Query Truxton

From truxwiki.com
Revision as of 07:49, 27 October 2021 by Sam (talk | contribs) (Created page with "Here's an example of how to query the Truxton database using Python. =Number of File Types= This will tell you how many types of files Truxton knows about. <source lang="pyt...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Here's an example of how to query the Truxton database using Python.

Number of File Types

This will tell you how many types of files Truxton knows about.

import sys
sys.path.append('C:/Program Files/Truxton/SDK')
import truxton
import psycopg2
import psycopg2.extras

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

  connection = psycopg2.connect(t.connectionstring)
  database_cursor = connection.cursor(cursor_factory=psycopg2.extras.DictCursor)
  database_cursor.execute("SELECT * FROM \"FileType\";")
  database_rows = database_cursor.fetchall()

  print( "There are " + str(len(database_rows)) + " file types in Truxton" )
  return

if __name__ == "__main__":
  main()