Difference between revisions of "Query Truxton"
Jump to navigation
Jump to search
| Line 2: | Line 2: | ||
To install the PostgreSQL library for Python: | To install the PostgreSQL library for Python: | ||
| − | <pre>pip install | + | <pre>pip install psycopg</pre> |
=Number of File Types= | =Number of File Types= | ||
| Line 11: | Line 11: | ||
sys.path.append('C:/Program Files/Truxton/SDK') | sys.path.append('C:/Program Files/Truxton/SDK') | ||
import truxton | import truxton | ||
| − | import | + | import psycopg |
| − | |||
def main(): | def main(): | ||
t = truxton.create() | t = truxton.create() | ||
| − | connection = | + | connection = psycopg.connect(t.connectionstring) |
| − | database_cursor = connection.cursor( | + | database_cursor = connection.cursor() |
database_cursor.execute("SELECT * FROM \"FileType\";") | database_cursor.execute("SELECT * FROM \"FileType\";") | ||
database_rows = database_cursor.fetchall() | database_rows = database_cursor.fetchall() | ||
Revision as of 16:39, 27 July 2022
Here's an example of how to query the Truxton database using Python.
To install the PostgreSQL library for Python:
pip install psycopg
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 psycopg
def main():
t = truxton.create()
connection = psycopg.connect(t.connectionstring)
database_cursor = connection.cursor()
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()