marglix

Untitled

Oct 8th, 2020
1,047
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import nimcx
  2. import nimfdb
  3.  
  4. # example to run 2 cursors to different databases
  5. # main issue is connectedflag may mess things up
  6. # we need to track which cursor is connected or have
  7. # some object to do the tracking somehow issue see line 55
  8.  
  9. type
  10.      Ctrack = object
  11.        name : string
  12.        cflag: bool  
  13.  
  14. let user = "sysdba"
  15. let pwx = "somepw"
  16. let dsn1 = "10.0.0.2:/media/veracrypt5/isocountry3.fdb"  # adjust accordingly
  17. let dsn2 = "10.0.0.2:/home/lxuser/Downloads/python3-driver/test/fbtest30.fdb"      
  18. var acon:PyObject
  19. var bcon:PyObject
  20.  
  21. var aquery = "select first 1 c.iso,c.NAME,c.PRINTABLE_NAME, c.ISO3, c.NUMCODE  from COUNTRY c order by rand()"
  22. var ctracka:Ctrack
  23. var ctrackb:Ctrack
  24.  
  25. proc doConnectA()=
  26.      acon = fbconnect(dsn1,user=user,pw=pwx,fail=true)
  27.      ctracka.name = "acon"
  28.      ctracka.cflag = true
  29.      
  30. proc doConnectB()=
  31.      bcon = fbconnect(dsn2,user=user,pw=pwx,fail=true)
  32.      ctrackb.name = "bcon"
  33.      ctrackb.cflag = true
  34.    
  35.  
  36. for x in 0 ..< 5:
  37.   doconnectA()
  38.   showquery(fbquery(acon,aquery))
  39.   shutdown(acon,"acon")
  40.   ctracka.cflag=false
  41.  
  42.   doconnectB()
  43.   showQuery(fbquery(bcon,"SELECT first 5 * FROM employee r"))
  44.   fbConStatus(bcon,"bcon")
  45.   shutdown(bcon,"bcon")
  46.   ctrackb.cflag=false
  47.  
  48.   doconnectA()    
  49.   fbConStatus(acon,"acon")
  50.   showquery(fbquery(acon,aquery))
  51.   shutdown(acon,"acon")
  52.   ctracka.cflag=false
  53.  
  54.   doconnectB()
  55.   fbConStatus(acon,"acon")        # <----- wrong positive as fbconnect resets the connectedflag
  56.   echo " Ctracka        : ",ctracka.cflag  # if can put our object into nimfdb maybe we can overcome this issue  
  57.   fbConStatus(bcon,"bcon")
  58.   showQuery(fbquery(bcon,"SELECT first 15 * FROM employee r"))
  59.   shutdown(acon,"acon")  # close a already closed cursor ok
  60.   ctracka.cflag=false
  61.   shutdown(bcon,"bcon")
  62.   ctrackb.cflag=false
  63.   echo " Iteration      : ",x
  64.   echo()
  65.  
  66.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×