1. PostgreSQL demos

I added these demos to the wrapper.  So you who have already downloaded it
don't have to repeat that operation, I'll post them here.

Demo1.exw
--This demonstrates creating a database named ala(where did I get that name?).

include libpqfe.e

--conninfo holds the name of the database to
--connect to, usually postgres.
sequence conninfo

--conn holds a pointer to the conn structure
--res takes the result of PQexec commands.
atom conn, res

--put in the name of the db to connect to.
conninfo = "dbname = postgres"

--connect to that database selected above.
conn = PQconnectdb(conninfo)

--create database ala using PQexec and the commands below, just like you would
do in psql.
res = PQexec (conn, "CREATE DATABASE ala WITH OWNER = postgres2 ENCODING =
'SQL_ASCII' TABLESPACE = pg_default;")

--deallocate the conn structure, so there won't be memory leaks.
PQfinish(conn)

--put message and wait for user to press a key.
puts(1, "succesful")
while get_key() = -1 do end while

Demo2.exw
--This demonstrates opening a database, creating a table, and adding information
to it.

include libpqfe.e

--standard variables for most operations:
sequence conninfo
atom conn, res

--select ala as the database to connect to.
conninfo = "dbname = ala"

--connect to the database.
conn = PQconnectdb(conninfo)

--create a table named cities, with a varchar[80]; name, and a point; location.
--standard SQl commands.
res = PQexec(conn, "CREATE TABLE cities ( name varchar(80), location point );")


--now, populate table cities with the city of New York
res = PQexec(conn, "INSERT INTO cities VALUES ('New York', '(5, 10)');")

--free the conn structure
PQfinish(conn)


puts(1, "Done")
while get_key() = -1 do end while

Later,
Jeremy

Edmund Burke: "All that is necessary for evil to triumph is for good men to do
nothing."

new topic     » topic index » view message » categorize

2. Re: PostgreSQL demos

Jeremy,

I'm getting an error with both demos:

C:\INCLUDES\POSTGRESQL\libpqfe.e:617
c_proc/c_func: bad routine number (-1) 


Global & Local Variables

 C:\EUPHORIA\include\machine.e:
    mem = 960136
    check_calls = 1

C:\Documents and Settings\cklester\Desktop\Euphoria
 Apps\PostgresSQLwrap1.1\Demos\Demo1.exw:
    conninfo = <no value>
    conn = <no value>
    res = <no value>

-=ck
"Programming in a state of Euphoria."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

3. Re: PostgreSQL demos

Ck, it looks like you didn't place the libpqfe.dll AND the dlls that are in your
postgresql/8.?/bin directory in c:\windows\system?

Jeremy

Edmund Burke: "All that is necessary for evil to triumph is for good men to do
nothing."

new topic     » goto parent     » topic index » view message » categorize

4. Re: PostgreSQL demos

Jeremy Peterson wrote:
> 
> Ck, it looks like you didn't place the libpqfe.dll AND the dlls that are in
> your postgresql/8.?/bin directory in c:\windows\system?

Just downloaded the latest package and there's a problem in fstream.e:

    atom fstream_h, atom def_fstream

should probably be

    atom fstream_h, def_fstream


-=ck
"Programming in a state of Euphoria."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

5. Re: PostgreSQL demos

Also, in libpqfe.e, line 1254 needs another dash at the beginning:

   -1 is returned if the given name does not match any column.

should be

   --1 is returned if the given name does not match any column.

-=ck
"Programming in a state of Euphoria."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

6. Re: PostgreSQL demos

On line 1492 and line 1513,

   sequence mode

should be

   sequence fmode

(I think.) :)

-=ck
"Programming in a state of Euphoria."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

7. PostgreSQL demos

Whoa!  Attack of the killer bugs!  I'll get right to work fixing these, thanks
CK!

Jeremy

Edmund Burke: "All that is necessary for evil to triumph is for good men to do
nothing."

new topic     » goto parent     » topic index » view message » categorize

8. Re: PostgreSQL demos

Jeremy Peterson wrote:
> 
> Whoa!  Attack of the killer bugs!  I'll get right to work fixing these, thanks
> CK!

Yeah, sorry 'bout that! I should always make a text file first and then send
the email, but... nah! This list needs the excitement and traffic. :)

I've made the changes to my code, of course, and I'm getting this error
message:

   [Titlebar]EXW.EXE - Unable to Locate Component
   [X] This application has failed to start because libpq.dll was not found.
       Re-installing the application may fix this problem.

I did a search of my drive and didn't find libpq.dll, but I do have PostgreSQL
installed successfully because I can use pgAdminIII to manage databases.

Lemme know what I should do. I'm going to keep looking for that libpq.dll.
Maybe it's hidden!

-=ck
"Programming in a state of Euphoria."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

9. Re: PostgreSQL demos

cklester wrote:
> Yeah, sorry 'bout that! I should always make a text file first and then send
> the email, but... nah! This list needs the excitement and traffic. :)
> 
> I've made the changes to my code, of course, and I'm getting this error
> message:
> 
>    [Titlebar]EXW.EXE - Unable to Locate Component
>    [X] This application has failed to start because libpq.dll was not found.
>        Re-installing the application may fix this problem.
> 
> I did a search of my drive and didn't find libpq.dll, but I do have PostgreSQL
> installed successfully because I can use pgAdminIII to manage databases.
> 
> Lemme know what I should do. I'm going to keep looking for that libpq.dll.
> Maybe it's hidden!
> 
> -=ck
> "Programming in a state of Euphoria."
> <a
> href="http://www.cklester.com/euphoria/">http://www.cklester.com/euphoria/</a>
If you don't have libpq.dll, I don't know how you could run postgresql.  It is
in binary distrobution of postgresql, so if you don't have it you can download
it.  When you do find it, you must put a copy of it and all dlls that are in the
postgresql bin directory in your windows\system directory.
This should fix your problem.

Jeremy

Edmund Burke: "All that is necessary for evil to triumph is for good men to do
nothing."

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu