psql restore from pg_dump file – invalid command \N

when searching for this error ‘invalid command \N’ when trying to restore my database from a backup I made with the following:

$ pg_dump -d foo -t bar > bar.psql

I got lots of suggestions but what I needed was to drop the darn table before restoring it …

$psql
foo=> drop table bar;

$psql < bar.psql

julia postgres libpq update example

The Julia community seems shy about posting examples of database things…

use LibPQ, Tables

db="db" 
server="localhost" 
usr="psql"
passwd="nope"

conn = LibPQ.Connection("host=$server dbname=$db user=$usr password=$passwd")
sql = """select char from foo""" 

conn2 = LibPQ.Connection("host=$server dbname=$db user=$usr password=$passwd") 
sql2 = prepare(conn2, """update bar set agility = \$1 , bravery = \$2 where char = \$3""" ) 

response = execute(conn, sql) 

for row in rowtable(response)
  ag = agility(row[:char])
  br = bravery(row[:char])
  execute(sql2, (ag, br, row[:char]))
end

Goodbye linksys

So the last time I purchased a new wireless router – I tried to find a wireless router that had a future – something where I could replace the stock firmware once the software updates stopped coming from the manufacture. But by this time linksys had sold its soul and stopped shipping wireless routers with the serial headers – my EA6350v2 was one such of these, prior to attempting to solder on pins or making a clothespin serial doohickey, I purchased a backup EA6350v2 off ebay so I wouldn’t have to repeat the cycle if I botched the job. Fortunately the backup EA6350v2 had the serial port pins so I was able to get ddwrt going with out too much fuss. However a few weeks in the wifi was behaving funky on this backup 6350v2 so I went looking for another router – I was looking for a new/better linksys router  but came across this sentence: as of October 2020, WE CANNOT ENDORSE BUYING A EA8500 ANYMORE – as linksys has started making it even harder to get alternate firmware installed.  So I picked up a Netgear r6300v2, cracked the case, loaded recent version of ddwrt via serial port and added linksys to my never list.

julia mysql mariadb dbinterface update

https://github.com/JuliaDatabases/DBInterface.jl  mariadb — mysql

while doing a query on “conn”, I opended second connection “conn2”, and updated the table while stepping through the results of the first query

conn = DBInterface.connect(MySQL.Connection,"localhost","user","pass",db="foo")
sql = """select char from foo"""
response = DBInterface.execute(conn,sql)
conn2 = DBInterface.connect(MySQL.Connection,"localhost","user","pass",db="foo")
sql2 = DBInterface.prepare(conn2, "UPDATE foo set agility = ?, bravery = ? where character = ?")
for row in response
    ag=agility(char)
    br=bravery(char)
    DBInterface.execute(sql2, (ag, br, char))
end

julia complains without the parens around the arguments on the DBInterace.execute line.

linksys EA6350v2 with dd-wrt

installing dd-wrt on a EA6350v2 from linux.

So linksys hasn’t released a firmare update for the EA6350V2 since 11/2017 and it is still on a 2.6 kernel, so I wanted to try to get to a newer kernel – DD-WRT supports EA6350v1 and the forum has tale of the same version working for the EA6350v1 working on the v2 – but you need to crack the case and use a serial port to upgrade.

My original EA6350v2 didn’t have headers on the serial port – guess they saved $0.05 that day – https://amzn.to/3dyEKxe $5 .

so I bought another router one off ebay (https://www.ebay.com/sch/i.html?_from=R40&_nkw=ea6350v2&_sacat=0&_sop=15) $23 – this one was built on a less cost cutting day and had the serial headers, I got a usb serial port off of ebay – something like this one https://amzn.to/2OnyKyO $6.

Then I hooked up my laptop to my “new” router via the serial port – you have to get the cover off the linksys, find the serial port – to the left of the big heat sink, the arrow marks the 3.3v pin (unused), next to that is TXD, then RXD, then GND (this is from left to right with the ports/antennae away from you. – you’re going to cross TXD from your serial adapter to RXD on the linksys, and RXD from your adapter to TXD with GND to GND.

I installed putty on linux – i know – and configured it to use /dev/ttyUSB0, 115200, 8,n,1 and connect to the serial port and voila I could watch my ea6350v2 boot and stop it during boot with ctrl + c which yeilds a CFE> prompt.

After getting the boot stopped, I connected my cross over cable between my linux laptop and one of the LAN ports on the router (not the one you connect to your cable modem/dsl box) and was able to ping 192.168.1.1 (the router) –

(i have a big box of ethernet cable and a crimper and rj45 connectors so I made my own cross over cable long ago – the router might automatically do the cross over for you or you can get your own cross over cable https://amzn.to/3fRIFbl  $5).

(My laptop doesn’t have a wired ethernet port so I used a older relative of this https://amzn.to/3sUxJNO $ 19. )

My network port was actually already configured with a 192.168.1.x address but you can just bring it up with

$ sudo ifconfig <interface> inet 192.1.1.2 netmask 255.255.255.0

then on the router (via serial port) I typed:

CFE> flash -noheader : nflash0.trx

it said Reading :

then on the linux command line I typed

$ tftp 192.168.1.1
tftp> binary

tftp> put put linksys-ea6350-webflash.bin

71 seconds later the router (via serial) said programming and eventually returned to the CFE> prompt where I asked it to flash to the other location.

CFE> flash -noheader : nflash0.trx2

and I then repeated the above tftp put command

and another 71 seconds later it said programming again and after a bit returned to the CFE> prompt

after powercycling the linksys it came up running DD-WRT.