[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Postgres Access Timing



On Fri, 2009-07-24 at 10:05 -0700, Chris Travers wrote:
> How are you determining the customer/vendor that was inserted as well
> as the part?
> 

The vendor is a set depending on which file is being processed. For now
anyway it's hardcoded from looking at the vendor table with phppgadmin.
I'm not using the customer bits of a part at the moment. The part_id is
got from the part when created. The actual line sent to postgres is
correct - I print it on the terminal and cut and paste to SQL when it
fails and that works (eventually sometimes) so I'm 100% confident that
the c program's output has both correct syntax and semantics.

This morning an INSERT failure is crashing the program (stack smashing)
which is nice, so I'm going to have a go at creating and dropping the
connection to the dbase for each command - having read the library
documentation again it's not 100% clear if that should be done, or just
keep using the same connection while dealing with each part.

Cheers
Richard

> On Fri, Jul 24, 2009 at 7:43 AM, beamends <..hidden..> wrote:
>         
>         
>         On Fri, 2009-07-24 at 09:01 -0400, Eric Lucas wrote:
>         > Richard:
>         >
>         > Is this injection part of an ongoing process or just a
>         one-time import
>         > of data?
>         >
>         > If you're only going to do this once then you might want to
>         try
>         > importing the data by using a spreadsheet to construct the
>         necessary SQL
>         > INSERT statements.  It will load slower than your program
>         would load
>         > them but depending on the amount data it's tolerable.
>         >
>         >
>         > Here's what I do...
>         >
>         > Copy the data into a spreadsheet.
>         >
>         > Re-order and/or duplicated the columns of data as necessary
>         for the next
>         > step
>         >
>         > Insert empty columns and place SQL fragments in these new
>         columns
>         >
>         > You can create multiple inserts on the same line (for
>         multiple tables
>         > for example) by separating them with a semi-colon and
>         duplicating
>         > columns of data as required.
>         >
>         > When the syntax is correct then export it as a delimited
>         file (for
>         > example, delimited by a pipe character: |  ).
>         >
>         > Use an programmable editor (like VIM, JEdit, bbedit, etc.)
>         to remove all
>         > the pipe characters and the resulting file can be executed
>         from the
>         > command line.
>         >    (in VIM I just enter the following command to remove the
>         delimiters
>         > all at once):
>         >      :%s/|//g
>         >
>         >
>         > You can also insert several sample rows in the tables and
>         then dump them
>         > them and modify the dump file to contain your entire data
>         set.   I
>         > believe that data is tab-delimited.
>         >
>         >
>         >
>         > Hope this helps,
>         >
>         > Eric
>         
>         
>         Hi Eric,
>         sadly it's a monthly thing, updating prices and new parts from
>         two (or
>         more maybe) suppliers, and checking who's doing the best price
>         this
>         month.
>         
>         Dumping the data, updating and then putting back may be an
>         option later
>         though if I can get this working!
>         
>         Thanks for the reply!
>         
>         Cheers
>         Richard
>         
>         
>         
>         >
>         > beamends wrote:
>         > > Hi All,
>         > > not strictly a LSMB thing, but as the answer may be of
>         interest to
>         > > others here goes... (excuse the terminology, I'm not of
>         the dbase expert
>         > > persuasion)
>         > >
>         > >
>         > > I'm "injecting" data into Postgres using a C program via
>         libpq. From the
>         > > documentation it's not clear if the various functions
>         check/wait to see
>         > > if a dbase command has been or can be completed before
>         returning from
>         > > the function ("locking"?). All is tickety-boo except when
>         creating a new
>         > > part. When the new part is created the next line is to
>         create the
>         > > partsvendor table entry. This works ok for most of the
>         time, but will
>         > > start failing after a while with the INSERT into
>         partsvendor failing.
>         > > Doing the command from the SQL window in phppgadmin will
>         then work.
>         > > Presumably this is a timing issue or such. So the question
>         is, is there
>         > > and SQL or Posgres command to interrogate the dbase to see
>         if it is
>         > > "ready" for the next command. Or am I barking up the wrong
>         tree
>         > > entirely!
>         > >
>         > > Cheers
>         > > Richard
>         > >
>         > >
>         > >
>         ------------------------------------------------------------------------------
>         > > _______________________________________________
>         > > Ledger-smb-users mailing list
>         > > ..hidden..
>         > >
>         https://lists.sourceforge.net/lists/listinfo/ledger-smb-users
>         > >
>         >
>         
>         
>         ------------------------------------------------------------------------------
>         _______________________________________________
>         Ledger-smb-users mailing list
>         ..hidden..
>         https://lists.sourceforge.net/lists/listinfo/ledger-smb-users
>         
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Ledger-smb-users mailing list
> ..hidden..
> https://lists.sourceforge.net/lists/listinfo/ledger-smb-users