Database Guide : Getting Started with PostgreSQL
Getting Started with PostgreSQL
PostgreSQL is a SQL compliant relational database management system and a relatively new feature to the VAST Platform product. At this time, VAST supports PostgreSQL at the in the base (ST:) database framework . You can access the PostgreSQL code by loading the “ST: Database, PostgreSQL” feature, or the “ST: Database PostgreSQL Glorp” feature.
The current PostgreSQL database support requires that the database be local to where you are running your image (localhost).
Making a connection to a PostgreSQL database requires that OpenSSL dlls to be available to your image. You can either install your own OpenSSL support (see FAQ va09002) or use the ones that are installed with PostgreSQL.
If you choose the later, you will need to
update abt.ini entries to something like the following (assuming x64 system):
CRYPTO_LIB=libcrypto-1_1-x64
SSL_LIB=libssl-1_1-x64
add the PostgreSQL bin folder to your PATH.
restart your VAST image (if it is open) once all of this is on place.
Here is a simple Smalltalk script that demonstrates how to connect / disconnect to/from a PostgreSQL database and how to do a few simple queries. Replace the three values in < > with your specific values:
| conSpec logonSpec sqldef table connection
newRow existingRow inValue outValue |
conSpec := AbtDatabaseConnectionSpec
forDbmClass: #AbtPostgreSQLDatabaseManager
databaseName: '<dbname>'.
logonSpec := AbtDatabaseLogonSpec
id: '<userid>'
password: '<password>'
server: nil.
connection :=
conSpec
connectUsingAlias: 'TestConSpec'
logonSpec: logonSpec.
connection executeCallForSQLStatement: 'DEALLOCATE ALL'
ifError: [ :err | ].
 
sqldef := '(data_field date)'.
connection deleteTableNamed: 'data_test'
ifError: [ :err |].
table := connection
createTableNamed: 'data_test' definition: sqldef.
Transcript cr;
show: ((connection openTableNamed: 'data_test') columnNames)
printString.
inValue := Date today.
newRow := table emptyRow.
newRow at: #data_field put: inValue.
table addRow: newRow.
Transcript cr; show: (table asStrings) printString.
existingRow := (connection resultTableFromQuerySpec:
((AbtQuerySpec new) statement: 'select * from data_test')) next.
outValue := existingRow at: #data_field.
( inValue = outValue )
ifFalse: [ self halt ].
connection deleteTableNamed: 'data_test'.
"Disconnect from a database"
connection disconnect.
 
Last modified date: 02/26/2021