Re: pasting a lot of commands to psql
От | Adrian Klaver |
---|---|
Тема | Re: pasting a lot of commands to psql |
Дата | |
Msg-id | 66ca662c-a1fa-df4c-7019-868a60ed7ee2@aklaver.com обсуждение исходный текст |
Ответ на | Re: pasting a lot of commands to psql (Dmitry Shalashov <skaurus@gmail.com>) |
Список | pgsql-general |
On 07/07/2016 10:41 AM, Dmitry Shalashov wrote: >> Have you also tried simplifying the sql for multiple values in one > statement? > this is another possible solution, but it's not answering my general > "why is this happening" question. When I have seen this I put it down to encoding issues. It happens most often when I cut and paste from places like this list, where sometimes strange/hidden characters are swept up in the cut and then do not translate into the paste. > > This is happening with PostgreSQL 9.5.3 and psql 9.5.3, but actually I > am seeing this for a few years... Since I started to use PostgreSQL > actively I believe. > > > Dmitry Shalashov, surfingbird.ru <http://surfingbird.ru> & relap.io > <http://relap.io> > > 2016-07-07 20:36 GMT+03:00 Melvin Davidson <melvin6925@gmail.com > <mailto:melvin6925@gmail.com>>: > > > > On Thu, Jul 7, 2016 at 1:33 PM, Dmitry Shalashov <skaurus@gmail.com > <mailto:skaurus@gmail.com>> wrote: > > > *\i your_file_name* > * > * > I actually mentioned this way in my original posting. In my case > it would involve copy-paste anyway - to create a file on a > system where I have psql opened. > I may do it that way. But why copy-paste directly to psql > results in this behaviour? > > > Dmitry Shalashov, surfingbird.ru > <http://surfingbird.ru> & relap.io <http://relap.io> > > 2016-07-07 20:30 GMT+03:00 Melvin Davidson <melvin6925@gmail.com > <mailto:melvin6925@gmail.com>>: > > This might seem a bit basic, but as long as you have a psql > session, why not just use > \i your_file_name > > On Thu, Jul 7, 2016 at 1:26 PM, Sameer Kumar > <sameer.kumar@ashnik.com <mailto:sameer.kumar@ashnik.com>> > wrote: > > > > On Fri, 8 Jul 2016, 1:23 a.m. Dmitry Shalashov, > <skaurus@gmail.com <mailto:skaurus@gmail.com>> wrote: > > Hi everyone. > > Let say that I have some sql file with like hundred > of simple statements in it. I `cat` it, copy it to > buffer, go to my beloved psql and insert it there. > But somewhere after first few lines it screws over: > > b2b=> BEGIN; > b2b=> INSERT INTO oko_topsites > VALUES('russian_federation','ati.su > <http://ati.su>',0,NULL,5); > INSERT INTO oko_topsites > VALUES('russian_federation'b2b=> INSERT INTO > oko_topsites VALUES('russian_federation','atn.ua > <http://atn.ua>',0,NULL,5); > b2b=> INSERT INTO oko_topsites > VALUES('russian_federation','audit-it.ru > <http://audit-it.ru>',0,NULL,5); > b2b=> INSERT INTO oko_topsites > VALUES('russian_federation','aup.ru > <http://aup.ru>',0,NULL,5); > ' > b2b=> INSERT INTO oko_topsites > VALUES('russian_federation','autocentre.ua > <http://autocentre.ua>',0,NULL,5); > > b2b=> INSERT INTO oko_topsites > VALUES('russian_federation','autodoc.ru > <http://autodoc.ru>',0,NULL,5); > > b2b=> INSERT INTO oko_topsites > VALUES('russian_federation','calend.ru > <http://calend.ru>' > > b2b(> INSERT INTO oko_topsites > VALUES('russian_federation','calorizator.ru > <http://calorizator.ru>',0,NULL,5) > > Unclosed quotes, unclosed parenthesis - anyway it > wont work. > > How to safely insert big number of statements to > psql at once? > I am aware about "execute this file" \i option of > psql, that is not the answer I am looking for, > thanks :-) > > > What are you exactly aiming to do? > > Have you tried - > psql < myfile > > > > Dmitry Shalashov, surfingbird.ru > <http://surfingbird.ru> & relap.io <http://relap.io> > > -- > -- > Best Regards > Sameer Kumar | DB Solution Architect > *ASHNIK PTE. LTD.* > > 101 Cecil Street, #11-11 Tong Eng Building, Singapore > 069 533 > > T: +65 6438 3504 | M: +65 8110 0350 | www.ashnik.com > > > >...I `cat` it, copy it to buffer, go to my beloved psql and > insert it there. > This might seem a bit basic, but as long as you have a psql > session, why not just use > *\i your_file_name * > > No need to cat, copy & paste! > -- > *Melvin Davidson* > I reserve the right to fantasize. Whether or not you > wish to share my fantasy is entirely up to you. > > > > It would help if you provided the version of PostgreSQL and the O/S. > > Have you also tried simplifying the sql for multiple values in one > statement? > eg: > INSERT INTO oko_topsites > VALUES > ('russian_federation','ati.su <http://ati.su>',0,NULL,5), > ('russian_federation','audit-it.ru <http://audit-it.ru>',0,NULL,5), > ... > ... > ('russian_federation','calorizator.ru > <http://calorizator.ru>',0,NULL,5); > > -- > *Melvin Davidson* > I reserve the right to fantasize. Whether or not you > wish to share my fantasy is entirely up to you. > > -- Adrian Klaver adrian.klaver@aklaver.com
В списке pgsql-general по дате отправления: