KDB - using a gui client - kdb

I'm just getting started using KDB again. At my old job everything was all set up on the server with a number of tables and I would just query the data. I'm now loading in my own data files and want to be able to query it from a GUI client.
The two I used in the past were QStudio and QPadInsight. For both of these, I need to connect to the server. I'm pretty sure I need to have it listen to localhost since the server is running on my desktop computer where the client is also running. I don't know what port to set it to. Also, do I need to do anything to have the server running other than opening a command prompt and running Q (c:\q\w32\q.q)?
Thanks for the help.

You only need to set the port for connecting it via qpad.
However, you can also load a specific file in that session from the command prompt.
c:\q\w32>q server.q -p 1234 //load the server.q file in q session
KDB+ 3.5 2017.11.30 Copyright (C) 1993-2017 Kx Systems
q)
If you are just bringing up the q session then you have to set the port and load some server-specific code manually.
c:\q\w32>q
KDB+ 3.5 2017.11.30 Copyright (C) 1993-2017 Kx Systems
q)\l server.q
q)\p 1234
Now it can be connected via qstudio or qpad using the connection string `::1234
Check this out to set the QHOME
You can set the QINIT variable to point to some q file that can act as the bootstrap file for all the q sessions you will run on your box (e.g. helper functions)
You can add the commands to a bat file to avoid any manual steps.
set QHOME=C:\q
set QINIT=C:\code\server.q
set PATH=%PATH%;%QHOME%;%QHOME%\w32
q -p 1234

Related

DB2 (version:11.5.0.1077) Command LIST ACTIVE DATABASES is not working

I downloaded trail version of DB2 (by following steps here:https://www.db2tutorial.com... some steps didn't come when i installed)and i opened Administrator:DB2 CLP - DB2COPY1 -db2, then i have given the cmd as
db2 => LIST ACTIVE DATABASES
output(error):
SQL1096N The command is not valid for this node type.
db2 =>
it's not working, here version of DB2 is:11.5.0.1077,Please advice how to proceed further.In fact not only this command, so many commands are not working.
The message:
"SQL1096N The command is not valid for this node type."
as a response to "list active databases" command
usually means that you did not install a Db2-server product, or you have multiple Db2-products installed and you chose to act on a client instance instead of a server instance.
You might have installed a full Db2-client product by accident, by clicking the wrong button on the setup program gui page for Install a product, or the installable image that you downloaded was not a server image (but instead a client image).
Different ways to see the node type:
You can see which Db2 product(s) you installed if you run
appwiz.cpl from the Windows Start menu and examine the list.
You can also see what you installed if you examine the log file created by the setup program during installation.
open a db2cmd.exe window (from Windows Start > Run) and in there run the command db2 get dbm cfg | more and near the start you will see Node type = ..... If your db2cmd.exe window is addressing a server installation, then the node type will be something like ...Server edition with local and remote clients. If you see Node type = Client, then you are not addressing a server installation. So in this case, you can either uninstall the client image and install a server image, or configure your db2cmd.exe window to address a server installation.
If you have multiple Db2 products installed then run the Default DB2 and Database Client Interface Selection wizard which should appear in your Windows Start menu under the IBM Db2 group. This lets you choose which instance to make the default, so that when you run a db2cwadmin/db2cmd window, then the correct product gets addressed.
If you installed a Db2-server product, then you can run db2cwadmin.bat (from the Windows Start Menu) and in that window the commands db2start and db2stop will be available, and the command-line db2 list active databases will report (by default) one local database called SAMPLE assuming you created the default database in the First Steps that runs after installation.
If you installed a Db2-server product, with all the default settings on a Microsoft Windows operating-system, then you will also see a process called db2sysc.exe in the Task List when the Db2-instance is running.
Verify that you downloaded the server image from IBM, and then re-run the setup program and ensure you choose to install a server product.

Mongodb community server on Windows 10: Can I access MongoDB shell command interpreter via ordinary telnet? (BEGINNER)

I am beginning to explore MongoDB and wish to write a small program/script using TCP socket to create a document in my local MongoDB community edition server. I would like to access MongoDB (which is now locally installed and running on my laptop) via a TCP socket.
I have installed MongoDB 4.2.3 community edition (with Compass.) As far as I can tell, it is running.
I can run mongo.exe shell:
C:\Program Files\MongoDB\Server\4.2\bin>mongo.exe
and the "show dbs" command yields what I would expect given that no documents or other data have been uploaded:
show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
Now, I would like to access mongodb via a TCP socket opened by my own (very small/simple) program so I can experiment with generating commands and observing responses (such as "show dbs").
When I telnet to localhost:27017 (using Windows 10 telnet client) telnet appears to connect to a socket (screen switches from "Connecting to localhost..." to a blank screen after a few seconds.)
As I am a beginner with MongoDB, I would appreciate a pointer as to how I can achieve my goal of using a small program I write to interact with MongoDB server.
Thank you, and I am happy to supply additional details as needed (and of course, would be grateful to a pointer to an example or other learning material that would help me proceed.)
Dave
MongoDB uses a custom wire protocol described here
If you are able to send binary values via telnet, you could probably make that work (I've no intention of trying)
You would probably find is simpler to use one of the pre-made drivers

breakpoints in eclipse using postgresql

I am using helios Eclipse for debugging my code in postgresql.
My aim is to know how postgresql uses join algorithms during the join query, so I started to debug nodenestloop.c which is in the Executor folder.
I gave break points in that file, But whenever I try to debug that file, the control goes to main.c and never comes back,How do I constraint the control only to that particular file(nodenestloop.c)
Below are the following fields which I gave in Debug configurations of Helios Eclipse.
C/C++ Application - src/backend/postgres and
project - pgsql
I followed the steps given in the following link for running the program.
https://wiki.postgresql.org/wiki/Working_with_Eclipse#
I even uncheked the field "Start on Start up=main" , but When I do that, The step in and Step over buttons are not activated and the following problem has popped up.
Could not save master table to file '/home/ravi/workspace/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources'.
/home/ravi/workspace/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources (Permission denied)
So I started eclipse using sudo, but this time the following error has come in the console of eclipse.
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise. See the documentation for
more information on how to properly start the server.
Could any one help me with this.
Thank you
Problem 1: User ID mismatch
Reading between the lines, it sounds like you're trying to debug a PostgreSQL instance that's running as the postgres user, or a different user ID to your own anyway. Hence your attempt to use sudo.
That's painful, especially when using an IDE like Eclipse. With plain gdb you can just sudo the gdb command to the desired uid, e.g. sudo -u postgres -p 12345 to attach to pid 12345 running as user postgres. This will not work with Eclipse. In fact, running it with sudo has probably left your workspace with some messed up file permissions; run:
sudo chown -R ravi /home/ravi/workspace/
to fix file ownership.
If you want to debug processes under other user IDs with Eclipse, you'll need to figure out how to make Eclipse run gdb with sudo. Do not just run all of Eclipse with sudo.
Problem 2: Trying to run PostgreSQL under the control of Eclipse
This:
"root" execution of the PostgreSQL server is not permitted. The server must be started under an unprivileged user ID to prevent possible system security compromise. See the documentation for more information on how to properly start the server.
suggests that you're also attempting to let Eclipse start postgres directly. That's very useful if you're trying to debug the postmaster, but since you're talking about the query planner it's clear you want to debug a particular backend. Launching the postmaster under Eclipse is useless for that, you'll be attached to the wrong process.
I think you probably need to read the documentation on PostgreSQL's internals:
Tour of PostgreSQL Internals
PostgreSQL internals through pictures
Documentation chapter - internals
Doing it right
Here's what you need to do - rough outline, since I've only used Eclipse for Java development and do my C development with vim and gdb:
Compile a debug build of PostgreSQL (compiled with ./configure --enable-debug and preferably also CFLAGS="-ggdb -Og -fno-omit-frame-pointer"). Specify a --prefix within your homedir, like --prefix=$HOME/postgres-debug
Put your debug build's bin directory first on your PATH, e.g. export PATH=$HOME/postgres-debug/bin:$PATH
initdb -U postgres -D $HOME/postgres-debug-data a new instance of PostgreSQL from your debug build
Start the new instance with PGPORT=5599 pg_ctl -D $HOME/postgres-debug-data -l $HOME/postgres-debug-data.log -w start
Connect with PGPORT=5599 psql postgres
Do whatever setup you need to do
Get the backend process ID with SELECT pg_backend_pid() in a psql session. Leave that session open; it's the one you'll be debugging.
Attach Eclipse's debugger to that process ID, using the Eclipse project that contains the PostgreSQL extension source code you're debugging. Make sure Eclipse is configured so it can find the PostgreSQL source code you compiled with too (no idea how to do that, see the manual).
Set any desired breakpoints and resume execution
In the psql session, do whatever you need to do to make your extension run and hit the breakpoint
When execution pauses at the breakpoint in Eclipse, debug as desired.
Basic misunderstandings?
Also, in case you're really confused about how all this works: PostgreSQL is a client/server application. If you are attempting to debug a client program that uses libpq or odbc, and expecting a breakpoint to trigger in some PostgreSQL backend extension code, that is not going to happen. The client application communicates with PostgreSQL over a TCP/IP socket. It's a separate program. gdb cannot set breakpoints in the PostgreSQL server when it's connected to the client, because they are separate programs. If you want to debug the server, you have to attach gdb to the server. PostgreSQL uses one process per connection, so you have to attach gdb to the correct server process. Which is why I said to use SELECT pg_backend_pid() above, and attach to the process ID.
See the internals documentation linked above, and:
PostgreSQL site - coding
PostgreSQL wiki - developer resources
Developer FAQ
Attaching gdb to a backend on linux/bsd/unix
I also faced similar issue and resolved it after some struggle
I misunderstood the following point under Debugging with child processes in the wiki (https://wiki.postgresql.org/wiki/Working_with_Eclipse).
5."Start postmaster & one instant of postgresql client (for creating one new postgres)"
The above step should be performed from terminal by starting postgres server and one client.
Hope this helps
Once this is done then debugger in eclipse needs to be started for C/C++ Attach to Application

PostgreSQL: Procedure or documentation for a strictly local installation

I am trying to do a local installation of a large but simple installation PostgreSQL 9.3.2 to hold about 14 GB of data, currently in a CSV file. This is my first attempt to install any database other than SQLite. The installer is asking me questions that I do not know how to answer and that seem inappropriate for an installation that I do not want to make available to the internet. I expect to be interacting with it through the R package RPostgreSQL. The database will contain primarily US Census data that is publicly available for free, and so not a tempting target. For instance, the installer asks me what port to use, and seems to require that I set a password. I prefer to set it up with no internet or remote accessibility at all, even from me.
Could someone tell me or point me toward documentation for producing a strictly local installation with minimal irrelevant hoops to jump through, both on installation and on use? I did a series of searches on variant of PostgreSQL & “install locally” or “local installation” or “create local database”, etc. but these were unproductive.
This will be on an ancient but lightly rebuilt Compaq laptop, Intel Core 2 Duo, Windows XP OS with SP3.
Any help folks could offer much appreciated.
If you're looking for an install that doesn't run a server and listen on TCP/IP, it isn't really possible, because PostgreSQL is a client/server database that (on Windows) communicates with clients solely over TCP/IP.
A "local only" install is one where the TCP/IP socket listens only on localhost, i.e. 127.0.0.1.
If you were really keen, you could not install the Windows service for the server at all, and just grab the binaries. To use PostgreSQL you would then have to initdb a new database directory, and start PostgreSQL when you wanted it with pg_ctl. See the user manual for details on these commands. When running, PostgreSQL would still be a server listening on a TCP/IP port, there's just no way around that on Windows.
On UNIX systems PostgreSQL can listen on a unix socket (a bit like a windows named pipe). This is not supported by PostgreSQL on Windows. Even then, it still has to run a server.
If you're looking for something like an embedded, on-demand, or in-memory PostgreSQL that runs out of the client library, there is no such thing.

How to check remote Oracle server is up and running

I have my Oracle server installed in a remote machine and I want a script at my local machine which will check whether Oracle server is up and running or not. I know this can be check by creating a connection through sqlplus or JDBC. But in this case oracle client won't be present and I am saving JDBC approach as my last option. So is there any other simpler way to check this, which can be easily implemented in a shell script???
Thanks
Not really. The only way to be certain that the database is responding to queries is to run a query on it, such as the venerable:
select dummy from dual