Got it working.
Jeeze, this database OBDC stuff is way more complicated than I expected it to be, and oddly enough, I previously knew it would be darn complicated.
OBDC is extremely finicky, every parameter must be perfect, every parameter changed requires a reinstallation of the initialization file and what makes it complicated is the fact that parameters are like in 5 different locations which needs to be checked upon. This is no good, would need to create some custom software to avoid this complexity. No tutorials or resources on how to get it working on FreeBSD is what kills me, thanks to FreeBSD forum, googling and GPT4o magic gets the trick done. Was a great learning experience on how to setup OBDC the old-school way, I can now simply download and install open source unixOBDC and get things rolling however I wish, this freedom is the beauty in the fruits of our labor.
Seems like I'm able to have the unixOBDC to install the driver (odbcinst.ini) and source (odbc.ini) initialization files as root user.
root@user:/usr/home/user # odbcinst -i -d -f /usr/local/etc/odbcinst.ini
Code:
odbcinst: Driver installed. Usage count increased to 2.
Target directory is /usr/local/etc
root@user:/usr/home/user # odbcinst -i -s -f /usr/local/etc/odbc.ini
Code:
root@user:/usr/home/user #
Is it normal when installing the source file like the above, for it to not return any sort of acknowledgment?
The
.ini file contents:
/usr/local/etc/
odbcinst.ini
Code:
[PostgreSQL]
Description=ODBC for PostgreSQL
Driver=/usr/local/lib/psqlodbcw.so
/usr/local/etc/
odbc.ini
Code:
Description = Test to Postgres
Driver = /usr/local/lib/psqlodbcw.so
Trace = Yes
TraceFile = /tmp/sql.log
Database = nike_footwear
Servername = 192.168.1.100
UserName = postgres
Port = 5432
Protocol = 6.4
ReadOnly = No
RowVersioning = No
ShowSystemTables = No
ShowOidColumn = No
FakeOidIndex = No
So here is what I've found which worked for me:
Login as root.
Set permissions:
chmod 644 /usr/local/etc/odbcinst.ini
chmod 644 /usr/local/etc/odbc.ini
Set Environment Variables:
setenv ODBCINI /usr/local/etc/odbc.ini
setenv ODBCINSTINI /usr/local/etc/odbcinst.ini
Verify Environment Variables:
echo $ODBCINI
echo $ODBCINSTINI
Now, here is the most crucial part, which took me days to figure out:
After setting the permissions and environment variables of the
.ini files, open a
new terminal and only then install the initialization files using
odbcinst
as root.
Since I'm creating a prototype database and would like no password at this stage, I would also need to update the
pg_hba.conf file:
nano /var/db/postgres/data16/pg_hba.conf
Add the following texts and save:
Code:
host nike_footwear postgres 192.168.1.100/32 trust
Now need to restart postgres:
service postgresql restart
Now lets connect to the PostgreSQL database using the
isql
utility provided by UnixODBC to see if ODBC works:
isql -v PostgreSQL
Code:
root@user:/usr/home/user # isql -v PostgreSQL
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| echo [string] |
| quit |
| |
+---------------------------------------+
SQL>
Thanks everyone for your great help, much obliged, now I still haven't got it connected to LibreOffice Spreadsheet yet... will try to get that figured out now.