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.
Sample Database Application for Programmers New to PureBasic
Re: Sample Database Application for Programmers New to PureB
I think this is a good starting point:
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: Select all
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
If something returns something, use DatabaseQuery()
If you use DatabseQuery() don't forget FinishDatabaseQuery()
host can also be an ip address like
Code: Select all
DB = OpenDatabase(#PB_Any, "host=127.0.0.1 dbname=Test port=5432", "User", "Password")
-
- Enthusiast
- Posts: 496
- Joined: Tue Oct 14, 2014 12:09 pm
Re: Sample Database Application for Programmers New to PureB
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
Thanks to infratec if he shows how to do and param postgresql server
Re: Sample Database Application for Programmers New to PureB
That's not PB relatedloulou2522 wrote:I think it will be necessary to show how to install a postgresql server.
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Sample Database Application for Programmers New to PureB
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.