<div dir="ltr">Hi guys,<br><br>I solved thanks to the suggestions of Berserker79 of the Italian forum [0].<br><br>I restored template1 thanks to this guide [1]<br><br>and I changed the connection string restoring the commented code.<br><br> $hConn.Close()<br> $hConn.Type = Lower(DBType)<br> $hConn.Host = DBHost<br> $hConn.Name = DBName<br> $hConn.Login = UserName<br> $hConn.Password = UserPassword<br> $hConn.Port = "5432"<br><br>and now all is OK.<br><br>Regards<br>Gianluigi<br><br>[0] <a href="https://www.gambas-it.org/smf/index.php?topic=7253.msg46682#msg46682">https://www.gambas-it.org/smf/index.php?topic=7253.msg46682#msg46682</a><br>[1] <a href="https://wiki.postgresql.org/wiki/Adventures_in_PostgreSQL,_Episode_1">https://wiki.postgresql.org/wiki/Adventures_in_PostgreSQL,_Episode_1</a></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno lun 2 set 2019 alle ore 15:22 Gianluigi <<a href="mailto:bagonergi@gmail.com">bagonergi@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi everyone,<br><br>I was creating a postgresql test database to verify the steps.<br>Unfortunately I must have done something wrong because at the final verification I get these results, which means that, if I understand correctly, instead of having populated the new "rubinettofelice" database with tables, I directly populated the template1.<br><br>This is how much is returned to me from the terminal:<br><br>=======================================================================<br>~$ psql -U postgres<br>Password for user postgres: <br>psql (11.5 (Ubuntu 11.5-0ubuntu0.19.04.1))<br>Type "help" for help.<br><br>postgres=# \l<br><br> Name | Owner | Encoding | Collate | Ctype | Access privileges <br>-----------------+-----------+----------+-------------+-------------+-----------------------<br> postgres | postgres | UTF8 | it_IT.UTF-8 | it_IT.UTF-8 | <br> rubinettofelice | gianluigi | UTF8 | it_IT.UTF-8 | it_IT.UTF-8 | <br> template0 | postgres | UTF8 | it_IT.UTF-8 | it_IT.UTF-8 | =c/postgres +<br> | | | | | postgres=CTc/postgres<br> template1 | postgres | UTF8 | it_IT.UTF-8 | it_IT.UTF-8 | =c/postgres +<br> | | | | | postgres=CTc/postgres<br>(4 rows)<br><br>postgres=# \du<br> List of roles<br> Role name | Attributes | Member of <br>-----------+------------------------------------------------------------+-----------<br> gianluigi | Create role, Create DB | {}<br> postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}<br><br>postgres=# \c rubinettofelice<br>You are now connected to database "rubinettofelice" as user "postgres".<br>rubinettofelice=# \d<br>Did not find any relations. <<========================================SIGH!<br><br>rubinettofelice=# \dn<br> List of schemas<br> Name | Owner <br>--------+----------<br> public | postgres<br>(1 row)<br><br>rubinettofelice=# \c template1<br>You are now connected to database "template1" as user "postgres".<br>template1=# \d<br> List of relations <<================ ???<br> Schema | Name | Type | Owner <br>--------+-------------------+----------+-----------<br> public | fipart | table | gianluigi<br> public | tagent | table | gianluigi<br> public | tagent_idagen_seq | sequence | gianluigi<br> public | tfilms | table | gianluigi<br> public | tfilms_idfilm_seq | sequence | gianluigi<br> public | tst_fi | table | gianluigi<br> public | tstars | table | gianluigi<br> public | tstars_idstar_seq | sequence | gianluigi<br>(8 rows)<br>=======================================================================<br><br>I created the database from the terminal with these steps.<br><br>1 - First I created the user:<br><br>=======================================================================<br>~$ psql -U postgres -d template1<br>Password for user postgres:<br>psql sql (11.5 (Ubuntu 11.5-0ubuntu0.19.04.1))<br>Type "help" for help.<br><br>template1=# CREATE ROLE gianluigi WITH CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD 'miapassword';<br>CREATE ROLE<br>=======================================================================<br><br>2 - Then I created the new "rubinettofelice" database:<br><br>=======================================================================<br>~$ psql -U test -d template1<br>Password for user test: <br>psql sql (11.5 (Ubuntu 11.5-0ubuntu0.19.04.1))<br>Type "help" for help.<br><br>template1=> CREATE DATABASE rubinettofelice WITH OWNER=gianluigi TEMPLATE= template1 ENCODING='utf-8';<br>CREATE DATABASE<br>=======================================================================<br><br>3 - At this point he created a Gambas project with a module (MBase.module):<br><br>=======================================================================<br>' Gambas module file<br><br><br>Private $hConn As New Connection<br><br>Public Sub OpenDB(DBType As String, DBHost As String, DBName As String, UserName As String, UserPassword As String)<br><br> $hConn.Close()<br> $hConn.Type = Lower(DBType)<br> $hConn.Host = DBHost<br> '$hConn.Name = ""<br> $hConn.Login = UserName<br> $hConn.Password = UserPassword<br> '$hConn.Port = "5432"<br><br> $hConn.Open()<br><br> If $hConn.Databases.Exist(DBName) Then<br> MakeTable()<br> Else<br> Error.Raise(("Database not found.\n\nAre you sure that the database exist?"))<br> Endif<br> <br> $hConn.Close()<br>Catch<br> Message.Error(Error.Text & "\n\n" & Error.Where)<br> FMain.Close()<br> <br>End<br><br>Public Sub CloseDB()<br> <br> $hConn.Close()<br> <br>End<br><br>Private Sub MakeTable()<br><br> Dim hTable As Table<br><br> $hConn.Begin<br><br> If Not $hConn.Tables.Exist("tstars") Then<br> hTable = $hConn.Tables.Add("tstars")<br> <br> hTable.Fields.Add("idstar", db.Serial)<br> hTable.Fields.Add("stname", db.String, 40)<br> hTable.Fields.Add("stsurn", db.String, 40)<br> hTable.Fields.Add("stheig", db.Integer)<br> hTable.Fields.Add("stweig", db.Integer)<br> hTable.Fields.Add("stbirt", db.Date)<br> hTable.Fields.Add("sttele", db.String, 13)<br> hTable.Fields.Add("idagen", db.integer)<br> hTable.Fields.Add("stimag", db.Blob)<br> hTable.PrimaryKey = ["idstar"]<br> hTable.Update<br><br> Endif<br> <br> If Not $hConn.Tables.Exist("tagent") Then<br> hTable = $hConn.Tables.Add("tagent")<br><br> hTable.Fields.Add("idagen", db.Serial)<br> hTable.Fields.Add("agname", db.String, 40)<br> hTable.Fields.Add("agsurn", db.String, 40)<br> hTable.Fields.Add("agaddr", db.string, 80)<br> hTable.Fields.Add("agcity", db.string, 40)<br> hTable.Fields.Add("agstat", db.string, 40)<br> hTable.Fields.Add("agcoun", db.string, 40)<br> hTable.Fields.Add("agpost", db.string, 10)<br> hTable.Fields.Add("agtele", db.String, 13)<br> hTable.Fields.Add("agmail", db.String, 30)<br> hTable.Fields.Add("agwebs", db.String, 30)<br> hTable.PrimaryKey = ["idagen"]<br> hTable.Update<br> Endif<br><br> If Not $hConn.Tables.Exist("tfilms") Then<br> hTable = $hConn.Tables.Add("tfilms")<br><br> hTable.Fields.Add("idfilm", db.Serial)<br> hTable.Fields.Add("finame", db.String, 100)<br> hTable.Fields.Add("fiyear", db.Date)<br> hTable.Fields.Add("fiprod", db.string, 100)<br> hTable.Fields.Add("fiboxo", db.Float)<br> hTable.PrimaryKey = ["idfilm"]<br> hTable.Update<br> Endif<br><br> If Not $hConn.Tables.Exist("tst_fi") Then<br> hTable = $hConn.Tables.Add("tst_fi")<br><br> hTable.Fields.Add("idstar", db.Integer)<br> hTable.Fields.Add("idfilm", db.Integer)<br> hTable.Fields.Add("sfpart", db.String, 20, "ND")<br> 'hTable.Indexes.Add("x_stfi", ["idstar", "idfilm"])<br> hTable.Update<br> Endif<br><br> If Not $hConn.Tables.Exist("fipart") Then<br> hTable = $hConn.Tables.Add("fipart")<br><br> hTable.Fields.Add("paname", db.String, 10)<br> hTable.Update<br> Endif<br><br> $hConn.Commit<br>Catch<br> $hConn.Rollback<br> CloseDB()<br> Debug Error.Where, Error.Text, Error.Code<br><br>End<br>=======================================================================<br><br>4 - In FMain I open a connection window that creates something similar and starts the module code:<br><br>MBase.OpenDB("postgresql", "localhost", "rubinettofelice", "gianluigi", "miapassword")<br><br>Can anyone help me figure out where I made the mistakes?<br><br>Regards<br>Gianluigi</div>
</blockquote></div>