How can I count the number of open connections in an sqlite database? - sqlite

I would like to count the number of open connections in an sqlite database. Is there a way to do that?

According to these posts on the mailing list there is no way to check the number of open connections through code or the database itself. There is no API.
According to this post, if you are running on a POSIX type system you can use the lsof command to count how many processes have opened the database.
If you are on Windows you can use Process Explorer to count the number of connections with the following steps:
In Process Explorer click on 'Find' -> Find Handle or DLL...
Type in the name of your sqlite database and click on 'Search' (or hit Enter)
In the results window, click on your database. It will become highlighted as a 'file' in the main Process Explorer window.
Back in the main window, right-click on your database file and click Properties
You can now see the number of References and Handles

An open file monitor like lsof will do it
lsof dbName.sql
will give you list of connection
OpenerName 6158 User 39u REG 1,2 20480 20397113 dbName.sql

Related

Can the qpad queries be recovered if qpad is closed but the port is open?

I ran multiple queries but before saving them, the qpad crashed. However the q-port on which these queries were running (on my windows machine) is still open. I can recover the variables and functions by \v and \f respectively.
Is there a way to recover all the q statements I ran using qpad? I forgot to maintain a log file, hence I am trying to find a way to recover queries using q-port.
Thanks
Unfortunately there's no way to retrieve your old queries for the reasons Davis.Leong said. But if you can't/don't want to create a table on your server to save them, you can also check the log queries box in QPad settings:
Q > Settings > Editor > Log queries to "queries_date.log"
Now when you run queries, they will be written to this log file in the same directory as QPad.exe, along with the server and timestamp, like this:
/ 02/26/19 09:54:52 on `:localhost:1234:: from QPad1*
show `logthis
/ 02/26/19 10:03:03 on `:localhost:1234:: from QPad1*
a:10
Unfortunately I don't think there is a way to retrieve your command history. Others has already mentioned why so I will not go into that. You can easily maintain a log file in the future however:
When you start your server, adding the -l flag will allow you to define a path to a log file. Any commands sent to the server from the client will now be logged. For example
q ../log/logtest -l -p 5555
t:([]date:`date$();sym:`sym$();price:`float$())
will start a q process listening on 5555, logging any messages that cause the server to update. So if I open a handle to 5555 in another q session h:hopen `::5555
and
update table t
q)h"insert[`t](2000.01.01;`appl;102.3)"
,0
the server will have updated t like so
q)t
date sym price
---------------------
2000.01.01 appl 102.3
There will be a log file created which will show any commands sent to the server. NOTE however it will only log those commands that change the state of the server's data.
This log file can be reloaded in the event of a server crash using the same command as before.
The answer is no. qpad is the GUI that interact with the q process. The reason why you can retrieve the variable and function is because the process did not die. For the query, in default q will not save that, unless when you customize your .z.pg to upsert a record in a queryHistory table.
e.g.
q).z.pg:{[x]`queryHistory insert ([]queryTime:.z.P;query:enlist x)}
q)queryHistory:([]queryTime:`timestamp$();query:())
q)10+10
20
q)testTab:([]sym:10?`1;val:10?100)
q)queryHistory
queryTime query
---------------
queryHistory is not append with record as this is being done in q process itself, if you do it in your qpad:
10+10
testTab:([]sym:10?`1;val:10?100)
you can see there will be record append, so even your GUI is crashed, you can trace the query
q)queryHistory
queryTime query
-------------------------------------
2019.02.26D17:32:38.471063000 "10+10"
q)queryHistory
queryTime query
----------------------------------------------------------------
2019.02.26D17:32:38.471063000 "10+10"
2019.02.26D17:32:52.790863000 "testTab:([]sym:10?`1;val:10?100)"
Got to know recently, there is a backup of your q scripts at "c/users//Appdata/local" and are autosaved every 5-6 mins.These are temporary files which are deleted when you save the script. However if your qPad crashed, you can find your files here :)

Control-m - Job´s in the line command

Is there any way to see Control-M Job´s in the line command ?
Eveyday I use the Control-M Enterprise Manager GUI, but I´m looking for any way to see all jobs in the line command.
Query the DB of Control-M Server:
Select * From Cms_Jobdef Where Tasktype = 'C '
If you have access to the API you will get the response in JSON format:
ctm run jobs:status
If you go to the "planning" or "monitoring" tools and then select "View" and then "List" (instead of "Map") then it will list all job in non-graphical mode - so you can see all the commands listed (where applicable).
If you have access to the Control-M Server machine itself then this query on the DB will list all commands (where the command line contains text) -
select SCHEDTAB, JOBNAME, CMDLINE from CMS_JOBDEF where CMDLINE IS NOT NULL;
Assuming that you are not using version 8 or higher, you can use CTRL+L on EM GUI to view the jobs as a list.
On the header of the list, right click and use the column chooser to choose to display the commands of the jobs.

Access 2010 Cannot share database across network

I have a 2010 Microsoft Access database in the format FixList.accdb
There is one table and one form in it, that i want a small number of users to access at the same time.
I have split the database, so that the back end is in a different folder to the front end.
Finally, i have gone to options and selected the following:
- Default Open Mode =Shared
- Default Record Locking = No locks
- Open Databases by using record-level locking (NOT ticked)
It opens fine when 1 user opens the database, but when a second user double clicks the Access file to open, the following message appears. "You do not have exclusive access to the database at this time. If you proceed to make changes, you may not be able to save them later". My question is, what other change(s) can i make to this database so that the error message above does not appear when more than one person opens the file?
Do NOT have more than one concurrent user open the same copy of the front-end (e.g., by having all users open the copy from a folder on the server). Each user must have their own local copy of the front-end .accdb/.accde file.

peoplesoft schedule query to external server

Is it possible in peoplesoft to schedule a query daily and transfer the result file (for example in xls) to a server or to a local drive ? In other words to extract the result out of the peoplesoft application itself? I don't mean to transfer it by mail...
Yes it is possible. You can create the query as a PSQUERY and then schedule the query.
See Scheduling Queries for more details
The summary is:
Create a query in PSQUERY
Schedule Query (Reporting Tools->Query->Schedule Query)
Select your runcontrol
Select your query (from #1) and enter parameters
Press Run
Change the type to File
Change the Format if needed (XLS is an option)
Enter the folder path in the output destination
Select a recurrence
Press OK
The output destination is from the point of view of the Process scheduler so c:\temp\ would put the files on the local drive of the process scheduler, not your PC. If the process scheduler has the correct permissions (and it's running on windows) you can put a UNC in here or in linux, you can mount the location you need and save it there.

How to set up ODBC 10.1b for Progress DB

I'm trying to set up an ODBC client driver for Progress 10.1b. I was able to install the client software that is required, but there is apparently also an ODBC.reg script file that needs to be run to correctly set up the registry in order for me to use the ODBC drivers.
Can anyone point me to where I would find this script? Or tell me the set of registry entries that would have to be made?
That's not a standard part of the install process.
Are these the steps that you followed to get the client installed?
If, as you say, the client was properly installed you just need to setup the DSN. The following should work (stolen and lightly edited from the Progress Knowledge Center):
Start up the ODBC Data Source Administrator(found in Control Panel within the Administrative Tools folder)
Example:
1. Select the System DSN tab
2. Select the Add button to the right
3. Select the MERANT 32-BIT Progress SQL-92 driver for your version of Progress.
4. Select Finish
That brings up the configuration screen for a new DSN.
Fill-in the following information:
1. Data Source Name..... (whatever you choose)
2. Description.......(optional and whatever you think is appropriate)
3. Host Name......(the server where the database is located)
4. Port Number.... (the port your database broker was started with...if multiple
brokers..the SQL broker port)
5. Database Name....(database name you wish to connect to)
6. User ID...(the user you logged in with or if security is turned on..a user
that can connect to the database)
7. Leave all other tab settings at the defaults for the initial configuration.
8. Select the Apply button.
9. Select the Test Connect button.
10. Screen requesting a password pops up. (enter one only if the database
normally requires a user name and password from the 4GL side to enter the database)

Resources