473,767 Members | 2,198 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

only seeing first of many COPY commands in input file

Hi,

I am trying to import data using COPY, from a file containing thirty or
so COPY commands each with 0 or more rows of data. Reason, I have a
small data set I want to include into a database with an identical
schema, with existing data. I figured a good way to do this would be to
use pg_dump on the small dataset, trim out the table definitions and
constraints, and run the resulting file. (I also reordered the COPY
statements to allow for FK constraints.)

$ psql -U username -f filename rachel_philly

The result I'm getting is that the first COPY statement is executed, and
none of the rest of them. No error messages appear. I've run through
several of the rest of the statements by commenting out the statement
that ran and running the file again, and in each case the data from the
first COPY statement is added to the database, but no data from any of
the rest of the COPY statements is imported.

When I restore normally from an untrimmed pg_dump file, all the COPY
statements are run without difficulty. I have read over the beginning
and end of the file but don't see anything that looks like a START ..
COMMIT block, or any similar thing that would flag for "run all of these
commands" vs. "only run the first command and then stop".

rachel=> select version();
version
------------------------------------------------------------------------------------------
PostgreSQL 7.4.6 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.3
(Debian 20040401)
(1 row)

rachel_philly=> \q

rachel@qbert /cygdrive/d/test
$ psql --version
psql (PostgreSQL) 7.4.2
contains support for command-line editing
I wouldn't think the version mismatch is causing this, since the full
restore works fine...

Any ideas on what I may be doing wrong, or further avenues of research
would be much appreciated!

Rachel
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #1
1 3540
We are loading a whole database using multiple copy command from inside a sql
script. Here is a couple of sample lines:

COPY choice FROM '/esc/pgrnd/prog/choice/choice.d.txt' DELIMITERS '|' WITH
NULL AS '?'; \i choice/choicePostLoad. sql;

COPY glacct FROM '/esc/pgrnd/prog/glacct/glacct.d.txt' DELIMITERS '|' WITH
NULL AS '?'; \i glacct/glacctPostLoad. sql;

We are also applying indicies and table/column comments to the tables after
the COPY command in the PostLoad files listed above.

I execute the command to load all this as:

psql rnd < load_data.sql

Do you have semi-colons at the end of each of the commands? By the way, I'm
running the same version as you.

On Thursday 18 November 2004 04:11 pm, Rachel McConnell saith:
Hi,

I am trying to import data using COPY, from a file containing thirty or
so COPY commands each with 0 or more rows of data. Reason, I have a
small data set I want to include into a database with an identical
schema, with existing data. I figured a good way to do this would be to
use pg_dump on the small dataset, trim out the table definitions and
constraints, and run the resulting file. (I also reordered the COPY
statements to allow for FK constraints.)

$ psql -U username -f filename rachel_philly

The result I'm getting is that the first COPY statement is executed, and
none of the rest of them. No error messages appear. I've run through
several of the rest of the statements by commenting out the statement
that ran and running the file again, and in each case the data from the
first COPY statement is added to the database, but no data from any of
the rest of the COPY statements is imported.

When I restore normally from an untrimmed pg_dump file, all the COPY
statements are run without difficulty. I have read over the beginning
and end of the file but don't see anything that looks like a START ..
COMMIT block, or any similar thing that would flag for "run all of these
commands" vs. "only run the first command and then stop".

rachel=> select version();
version
---------------------------------------------------------------------------
--------------- PostgreSQL 7.4.6 on i686-pc-linux-gnu, compiled by GCC gcc
(GCC) 3.3.3 (Debian 20040401)
(1 row)

rachel_philly=> \q

rachel@qbert /cygdrive/d/test
$ psql --version
psql (PostgreSQL) 7.4.2
contains support for command-line editing
I wouldn't think the version mismatch is causing this, since the full
restore works fine...

Any ideas on what I may be doing wrong, or further avenues of research
would be much appreciated!

Rachel
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


--
Quote: 67
"Nothing is more despicable than a professional talker who uses his
words as a quack uses his remedies."

--Francois de Salignac de la Mothe Fenelon

Work: 1-336-372-6812
Cell: 1-336-363-4719
email: te***@esc1.com

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5479
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
5
3598
by: Ariel Dolan | last post by:
Can I use HtmlInputFile to only get the selected file name but not actually upload the file? Clicking the control's Browse button let's the user select a file. All I need is the HtmlInputFile Value property. However, any button clicked on the Html page results in uploading the selected file. Is there a way to avoid the actual uploading? Alternatively, is there any other way to let a user select a file name from his local disk?
4
1834
by: William | last post by:
After much frustration I was able to update my data store via code only. Using the data adapter was the only way I was able to set up all the objects written in my code. Basically, I cheated by creating an adapter and then copy, paste, modify it's code to suite my needs. This was the end result: Private sub updateTable( ) Dim myData As DataSet 'Command is a form level oledbcommand object Dim Adapter1 As New OleDbDataAdapter(Command)
16
28492
by: Adam Witney | last post by:
Hi, Is it possible for the COPY command to read data from a file, but skip specific columns? Thanks Adam
10
6110
by: jimmy | last post by:
Hi again, sorry for posting two questions so close together but im working on a school project which is due in soon and running into some difficulties implementing the database parts. I have the code below which when executed generates the following error message: 'There is already an open datareader with this command which must be closed first' Private Sub MainMenu_Load(ByVal sender As System.Object, ByVal e As
206
8366
by: WaterWalk | last post by:
I've just read an article "Building Robust System" by Gerald Jay Sussman. The article is here: http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf In it there is a footprint which says: "Indeed, one often hears arguments against building exibility into an engineered sys- tem. For example, in the philosophy of the computer language Python it is claimed: \There should be one|and preferably only one|obvious...
3
419
by: cs | last post by:
Hi, I'm new to C and would appreciate any feedback on the following program, asplit, which splits a file into 2 new files, putting a certain number of lines in the first file, and all the rest in the second file. Any comments as to non-portability, stylistic infelicities, outright bugs or anything else would be very much appreciated.
9
15148
by: fniles | last post by:
I would like to copy a table(s) from SQL Server 2005 to a CVS file and vice versa. I was thinking to use the BCP command line utility, but I have a few questions: 1. The machine where I am going to run BCP utility does not have SQL Server installed, so BCP.exe and its underlying DLLs are not there. I copied BCP.EXE, then it tells me that it expects sqlncli.dll. After I copied that DLL, it now says "Unable to load BCP resource DLL. BCP...
1
3557
by: raocheng | last post by:
Please see the following code. Suppose I have many shell commands to be executed. And I don't want to fork a sub shell for each command(eg: status,output = commands.getstatusoutput(cmd)) because it is too expensive. I want to use only one sub shell to execute all these commands and want to get each command's output. How can I accomplish this task ? Thanks in advance. =========================================== #!/usr/bin/env python
0
9571
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10009
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9838
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6651
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5279
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.