Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Risingcognition.com 2009
What is QAT Database?
QAT is an abbreviation for Query-Able Text.
QAT is a storage system which parses structured plain text files in order to
make them query-able.
It’s basically a database engine targeted to small applications with stand-alone
data storage needs.
QAT uses simplified query language and perform all the basic tasks within the
table<>column philosophy.
QAT databases can be easily transported and accessed but the plain text is
encrypted to offer extra security to the application data.
QAT does not need runtimes, as long as .NET Framework 3.5 is installed in the
system.
QAT is simple, QAT is free! Why not power your application’s data with it?
Detach ()
Releases the QAT instance from its data bindings.
Returns: True if successful, False if not.
Authenticate (username,password)
Authenticates the caller onto the currently attached database.
Returns: True if successful, False if not.
CreateDatabase (dbname,username,password,dbfilepath)
Creates, attaches and a authenticates a database in the specified path
Returns: True if successful, False if not.
AddUser (username,password,accesslevel)
Adds a user to the currently attached database.
Remarks: See User access levels
Returns: True if successful, False if not.
RemoveTable (tablename)
Adds a column to a currently attached database’s table.
Returns: True if successful, False if not.
RemoveColumn (tablename,columnname)
Adds a column to a currently attached database’s table.
Returns: True if successful, False if not.
RemoveUser (username)
Adds a column to a currently attached database’s table.
Returns: True if successful, False if not.
TableExists (tablename)
Checks if the specified table exists in the database.
Returns: True if successful, False if not.
QATDB – Query-Able Text Database engine
Risingcognition.com 2009
ColumnExists (tablename,columnname)
Checks if the specified column exists in the database, within a table.
Returns: True if successful, False if not.
CountTables ()
Counts the number of tables in the database.
Returns: Count result.
CountColumns (tablename)
Counts the number of columns in the database, within a table.
Returns: Count result.
CountUsers ()
Counts the number of users in the database.
Returns: Count result.
GetTables ()
Gets a list of all tables in the database.
Returns: List of tablenames.
GetColumns (tablename)
Gets a list of all columns in the database, within a table.
Returns: List of column names.
GetUsers ()
Gets a list of all users in the database.
Returns: List of all user’s name and password.
GetTableAID (tablename)
Gets the table current Auto-ID.
Returns: Table current Auto-ID number.
ResetTableAID (tablename)
Resets the table Auto-ID, setting it to zero.
Returns: Table current Auto-ID number.
ExecuteQuery (query,returntype,firstonly)
Executes the specified query on the attached database.
Remarks: Return type is optional. Default is DataTable
Firstonly determines if only the first column from the first row is returned.
Firstonly is optional and has a default value of False.
Returns with Firstonly set to True can and should be treated as Strings
Returns: See Data Return.
TestDBConnection (databasefilepath)
Attempt a file open process to check file availability.
Returns: True if successful, False if not.
InstantSave ()
Force cache to be immediately written to database file.
Returns: Does not return.
ExecuteScript (script,detachatfinal)
Executes a given QAT Script file.
Remarks: detachatfinal determines if the database should be detached after a
script execution. Commonly used to run scripts that does not require
authentication.
Returns: True if successful, False if not.
Properties
AttachedAndAuthenticated
Checks if there is any database attached and authenticated.
Returns: True or false.
DataBaseName
Get or set database name.
Returns: Database name.
DebugMode
Get or set QAT debug mode. Debug mode will output errors.
Returns: True or false.
Commands
Ex:
LIST name,age FROM users WHERE age>=20
LIST name FROM users WHERE age>5,name&mar
Ex:
CHANGE age=22,gender=F FROM users WHERE name&(mar
Ex:
ADD users id=#?, name=Mary, age=20, gender=F
DELETE table
DELETE table WHERE col-OP-val,col-OP-val
Ex:
DELETE users WHERE age=22
COUNT table
COUNT table WHERE col-OP-val,col-OP-val
Ex:
COUNT users
COUNT users WHERE age =>20
Ex:
HIGHEST age FROM users
Ex:
LOWEST age FROM users
Ex:
FIRST id FROM users
Ex:
LAST id FROM users
Ex:
LUCKPICK tip FROM tips
Ex:
MATCHLIST Name,JobID FROM Users REPLACING JobID=Jobs>>Name>ID
Data return
List(Of String)
To keep QAT easy-to-use, the data returns are as simple as it can get.
After a query to the database, the execute method will return the type List (Of
String) filled with data structured as a table.
List(Of String) is not returned with named columns
Ex:
LIST id,name,age FROM users
Result:
1,Mary,22
2,John,24
3,Walter,34
The columns are comma separated and each item in the list represents a row.
List(Of Array)
Data can also be returned as a list of arrays.
Every list item represents a data row and every array item represents columns.
This return type is internally demodulated and does not need external
demodulation. List(Of Array) is not returned with named columns.
DataTable (default)
Data can also be returned as a datatable.
Datatable is filled with the information, making it accessible to the common
datatable usages such as data source to a combobox or datagrid.
This return type is internally demodulated and does not need external
demodulation. Datatable is returned with named columns.
QAT library includes tools, static methods that will help you in this process.
Every time data is inserted into the database, it needs to get modulated in order
to be flawlessly stored.
Consequently, every time you get a reply from a query, you need to demodulate
data, to translate QAT internal equivalents to characters we can understand,
preventing bad parsing as well.
Note1: Return types “Datatable” and “List(Of Array)” does not need demodulation.
Note2: QAT data type auto-detection now supports operations with time and dates in
the following format: DD-MM-YYYY HH:MM:SS
You can add a parameter to QAT Core, pointing its identity name and value.
AddParameter(Parameter As QATParameter)
AddParameter(New QATParameter(“myname”,”Johnny Walker (JR)”)
Note1: QATParameter’s identity name does not need “@” symbols when adding.
Note2: QATParameters does not need modulation.
Note3: QATParameters are cleared with every query execution.
Every instruction must end with the character “ ; ” and must obey to a command
syntax. QAT Script files are plain text but should have *.qatscript extension.
Commands
ATT databasefilepath;
TABLE tablename;
VAR variablename;
access levels.
Errorhandling
Internal error reporting has suffered some changes since version 0.415.
Everytime QAT Core catches an error, it will be thrown an exception, and this
exception should be caught as QATException.
Along with the exception, an event will be raised too. This event could be used
to maintain activity logs. The event is available through QAT Core.
Note: The event it’s not raised with every activity within QAT Core, but this
implementation is scheduled for the next version.
Errorhandle in VB.NET:
Try
QAT.SynchronizeInstance()
Catch ex As QATException
MsgBox(ex.Message & “ – “ & ex.InnerException.Message)
End Try