Running embedded VBA module inside Access database via Python [duplicate] - vba

This question already has answers here:
Python code for running ms-Access Module Subroutine
(2 answers)
Closed 1 year ago.
I have a VBA module/script inside Microsoft Access db as seen in the image below.
Normally I just click on green play button and it runs fine. This is just a sample script. The real script has many more queries so running the individual queries through Python is not the option. i.e. I can't just extract out query2 and run in python.
How do I make the entire module addSample() run via Python however.

You can use a socket for communication between Access and your Python script. For Python, this is trivial to open and use a socket. For Access, you could use this solution in your VBA code. Once the socket is connected, just pass strings as command/status messages between the programs.

Related

ExecutionHook with parallel runner [duplicate]

This question already has answers here:
Dynamic scenario freezes when called using afterFeature hook
(2 answers)
Closed 1 year ago.
I am using the parallel runner to run one of m feature files. It has 8 scenarios as of now. I wanted to integrate a third party reporting plugin (Extent report) to build out the reports. I planned to use the ExecutionHook interface to try and achieve this. Below are the issues i faced and havent found a even after looking at the documentation.
My issues
I am creating a new test on the afterFeature method. This gives me 2 handles, Feature and ExecutionContext. However since the tests are running in parallel, the reporting steps are getting mixed on each other? How do i handle this? Any out of the box method i can use?
To counter the above, i decided to build the whole report towards the end on the afterAll overridden method but here i am missing the execution context data so i cant use the context.getRequestBuilder() to get the urls and paths.
Any help would be great.
Please focus on the 1.0 release: https://github.com/intuit/karate/wiki/1.0-upgrade-guide
Reasons:
it gives you a way to build the whole report at the end, and the Results object can iterate over all ScenarioResult instances
ExecutionHook has been changed to RuntimeHook, see example
yes, since tests can run in parallel, it is up to you to synchronize as the framework has to be high performance, but building reports at the end using the Results object is recommended instead of using the RuntimeHook

How to open Solidworks, run macro, and close Solidworks from vb.net script? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am running a VBA Macro in solidworks that stops working and requires me to restart Solidworks after exactly 478 loop-itterations every time I run it.
Inside my loop, I open an STEP file, verify it, and then save it as an STL file. It appears as if Solidworks is struggling to open more than a fixed number of files in the same session.
My plan was to write a VB.NET script outside of Solidworks that can automatically restart the application without my intervention every X number of ittwerations, so I can process the thousands of files I have without my intervention.
VB.NET console script that closes and reopens Solidworks for me, whenever 477 itterations are reached, and then continues the macro from where it has left off.
The folders with my files are numbered, e.g.
c:\data\0\file.STEP
c:\data\1\file.STEP
c:\data\2\file.STEP
...
c:\data\20000\file.STEP
Specifically, I am looking for the VB.NET code that does the following:
Open Solidworks
Call an existing Macro-Script (possibly set a variable that lets me continue where I left of processing the data)
Close Solidworks
1) first you need to open solidworks and the file you want to process:
Open Assembly Document Example (VB.NET)
http://help.solidworks.com/2017/english/api/sldworksapi/open_assembly_document_example_vbnet.htm
2) you will need the openMacro2 function.
Here is a link with an example
https://forum.solidworks.com/thread/79502
3) then close all documents with the
CloseAllDocuments Method
http://help.solidworks.com/2017/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.ISldWorks~CloseAllDocuments.html
4) then exit solidworks with the ExitApp Method
https://help.solidworks.com/2017/english/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.ISldWorks~ExitApp.html
note: if you installed the api module you will find all needed examples in the apihelp.chm file which is located by default in:
C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\api
I took the liberty choosing version 2017 since you didn't mention the version you are using. But all examples should work on later versions too. If you are on an earlier version and you cannot find for instance openDoc7, then look at openDoc6 or openDoc5... until you find the number that is available on your system.

Running a test in golang that only works for some versions [duplicate]

This question already has answers here:
How do I skip a tests file if it is run on systems with go 1.4 and below?
(2 answers)
Closed 6 years ago.
I have a library here (https://github.com/turtlemonvh/altscanner) that includes a test comparing functionality of a custom scanner to bufio.Scanner. In particular, I am comparing my approach to the Buffer method which wasn't added until go1.6.
My actual code works with versions of go back to 1.4, but I wanted to include this test (and I'd like to add a benchmark as well) that uses the Buffer function of the bufio.Scanner object.
How can I include these tests that use features of go1.6+ while still allowing code to run for go1.4 and 1.5?
I imagine the answer is using a build flag to trigger the execution of these tests only if explicitly requested (and I do have access to the go version in my CI pipeline via a travis environment variable). I could also abuse the short flag here.
Is there a cleaner approach?
A few minutes after posting this I remembered about build constraints. Go has a built in constraint that handles this exact case, i.e. "version of go must be >= X".
Moving that test into a separate file and adding //+build go1.6 at the top fixed it.

Use Excel solver with calculations by an external program

Currently, I have a spreadsheet which uses an external program to do calculations (let's say it's an aerodynamic calculation tool). In Excel VBA, I update the inputs to the program via a UDF at the spreadsheet level ( =input("var1",1.234)).
Then, using VBA, I write the input file, run the external .exe, and read the output file. Outputs are again reported to the spreadsheet level via a UDF (=output("var2"))
I would like to use the Excel Solver function to make an optimization of the spreadsheet. Here, I would like it to change the input values ( via the =input() function) to get the optimum in the outputs (via the =output() function). The solver should be able to change the inputs, wait for the new calculation to be made (via the external .exe) and then resume when it gets the outputs.
So far I've found no reliable way to make it work. The Excel solver does not know that it needs to wait for the .exe to finish, even when I embed the shell(.exe) command in the input UDF....the solver still plows through as if nothing was happening.
Expectedly, it comes up with bunk since the output is out of sync with the input. I've pried open the SOLVER.XLAM (...ahemm..) to find a way to insert a wait statement, but that wasn't much help; the interface ends where the VBA interfaces with the SOLVER.dll, which places hooks into Excel to run the Excel calculation directly from the .dll ...so no help to me.
So far I'm stumped. Nobody seems to have encountered this before. I've tried looking into OpenSolver.org version, but they also end at some mysterious .dll or .exe interface. Any ideas?
(BTW: I have no access to the external program code, if you're wondering.... an .exe and some text files is all I get).
OpenSolver should work if you use the NOMAD solver, which does all calculations directly inside the spreadsheet. See http://opensolver.org/non-linear-nomad-integration/ for more information.

How can I call a PRO*C program directly from PL/SQL?

I couldn't find a similar question here.
I have a PRO*C program named pro_c.pc. How can I call and execute this in a piece of PL/SQL code?! Could someone give me a simple example?!
You can link external libraries (Windows DLL or UNIX ".so" files) to Oracle and then make them callable via PLSQL. This has been around at least since Oracle 8i.
This though requires DBA privs on the server to set this up, and is probably not a recommended approach these days .... but useful for crunching huge data.
See here for more details.
Calling a actual program directly, as opposed to a library function from PLSQL would be done indirectly via DBMS_SCHEDULER as #Justin suggested as the easiest way, creating a program with the PROGRAM_TYPE as EXECUTABLE. See here for more info.
A couple of things to note when doing this, the program will run as the (assuming UNIX) "oracle" user - bringing with it some security considerations, e.g. if the program creates a file it will be created as owned by oracle, and so might not be accessible to an "application" user. The program will run on the Oracle database server.