It is currently Thu Dec 03, 2020 4:41 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Sample Database Application for Programmers New to PureB
PostPosted: Wed Jul 01, 2020 6:40 am 
Offline
New User
New User
User avatar

Joined: Wed Jul 01, 2020 5:49 am
Posts: 5
Hello. nice meeting you. I'm starting to learn the language. I was looking for some postgres sample and found this thread, tried to get purebasicdatabaseapp.zip but the server is not online. Could you please help me to find another resource to get this.
Regards.


Top
 Profile  
Reply with quote  
 Post subject: Re: Sample Database Application for Programmers New to PureB
PostPosted: Wed Jul 01, 2020 7:50 am 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5075
Location: Germany
I think this is a good starting point:
Code:
EnableExplicit

Define DB.i, SQL$

UsePostgreSQLDatabase()

DB = OpenDatabase(#PB_Any, "host=localhost dbname=Test port=5432 connect_timeout=5", "User", "Password")
If DB
  Debug "Database open"
 
  SQL$ = "SELECT * FROM test"
 
  If DatabaseQuery(DB, SQL$)
    While NextDatabaseRow(DB)
      Debug GetDatabaseString(DB, 0)
    Wend
    FinishDatabaseQuery(DB)
  Else
    Debug SQL$
    Debug DatabaseError()
  EndIf
 
  SQL$ = "INSERT INTO test (col1, col2) VALUES ('1', '2')"
  If Not DatabaseUpdate(DB, SQL$)
    Debug SQL$
    Debug DatabaseError()
  EndIf
 
  CloseDatabase(DB)
Else
  Debug DatabaseError()
EndIf


For everthing which doesn't return something, you should use DatabaseUpdate()
If something returns something, use DatabaseQuery()
If you use DatabseQuery() don't forget FinishDatabaseQuery()

host can also be an ip address like
Code:
DB = OpenDatabase(#PB_Any, "host=127.0.0.1 dbname=Test port=5432", "User", "Password")


Top
 Profile  
Reply with quote  
 Post subject: Re: Sample Database Application for Programmers New to PureB
PostPosted: Thu Jul 02, 2020 9:01 am 
Offline
Enthusiast
Enthusiast

Joined: Tue Oct 14, 2014 12:09 pm
Posts: 318
I think it will be necessary to show how to install a postgresql server. It's not like sqlite which dosen't need anaything to install.
Thanks to infratec if he shows how to do and param postgresql server


Top
 Profile  
Reply with quote  
 Post subject: Re: Sample Database Application for Programmers New to PureB
PostPosted: Thu Jul 02, 2020 9:03 am 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5075
Location: Germany
loulou2522 wrote:
I think it will be necessary to show how to install a postgresql server.


That's not PB related :wink:


Top
 Profile  
Reply with quote  
 Post subject: Re: Sample Database Application for Programmers New to PureB
PostPosted: Thu Jul 02, 2020 10:19 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6262
Location: Wales, UK
https://www.postgresqltutorial.com/install-postgresql

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye