Thread: New user question -- alternate programmer interfaces?
To make a long story short, I've recently been learning PostgreSQL (and SQL in general) in a sort of trial-by-fire fashion. I copied the .pdf of Bruce Momjian's book onto my iBook and hacked out some code while I was traveling on business for a couple of weeks, largely without benefit of connectivity to a host where I could test things. Now I have about 1000 lines of doubtless very buggy code --- and I don't see any way to feed it to PostgreSQL for parsing other than to copy and paste into psql. (Aside from the obvious frustrations, psql seems to lock up whenever I paste more than about 15 lines of code into it.) Obviously I'm missing something. I assume there's a emacs mode for interacting with PostgreSQL from within emacs? Or at least some way to feed PostgreSQL a text file of code and have it spit back debugging info? Thanks in advance for any pointers!
You could put it in a file and feed it to psql like psql <db-name> < codefile.sql -Mitch ----- Original Message ----- From: "Carl Alexander" <carl_alexander@terc.edu> To: <pgsql-general@postgresql.org> Sent: Thursday, August 17, 2000 11:49 PM Subject: [GENERAL] New user question -- alternate programmer interfaces? > To make a long story short, I've recently been learning PostgreSQL > (and SQL in general) in a sort of trial-by-fire fashion. I copied > the .pdf of Bruce Momjian's book onto my iBook and hacked out some > code while I was traveling on business for a couple of weeks, > largely without benefit of connectivity to a host where I could > test things. Now I have about 1000 lines of doubtless very buggy > code --- and I don't see any way to feed it to PostgreSQL for > parsing other than to copy and paste into psql. (Aside from the > obvious frustrations, psql seems to lock up whenever I paste more > than about 15 lines of code into it.) > > Obviously I'm missing something. I assume there's a emacs mode for > interacting with PostgreSQL from within emacs? Or at least some > way to feed PostgreSQL a text file of code and have it spit back > debugging info? > > Thanks in advance for any pointers! > > >
On Fri, Aug 18, 2000 at 09:39:53AM -0700, Mitch Vincent wrote: > You could put it in a file and feed it to psql like > > psql <db-name> < codefile.sql I find a slight variation on this most userful (this is for bash: season redirects for your flavor of shell): psql -e <db-name> <codefile.sql 2>&1 | less then search in less for the string ERROR Or, if you want to do code fragments, tale a look at the \i command in psql. (hit \? in psql to get a list of all the slash commands) Ross
>>>>> "Carl" == "Carl Alexander" <carl_alexander@terc.edu> writes: Carl> I assume there's a emacs mode for interacting with PostgreSQL Carl> from within emacs? M-x sql-postgres, provided you've the right stuff installed. To my best of memory the proper package is available from the GNU ftp server, if you haven't already got it. But just for loading scripts I find psql's \i [filename] to be much more painless, especially since psql generally is nicer to work with in daily use than the equivalent Emacs mode. Each, of course, have their benefits. Martin -- GPG public key: http://home1.stofanet.dk/factotum/gpgkey.txt