Simplest Way to Test ODBC on WIndows - odbc

With unixODBC you can use a simple command line utility called "isql" to test your connection and permissions of some queries. Without having to write extra code or install libs or bloated programs, is there a simple way to open up X data source send some sql commands and be done with it?
Doing this on the command line would be preferable.

One way to create a quick test query in Windows via an ODBC connection is using the DQY format.
To achieve this, create a DQY file (e.g. test.dqy) containing the magic first two lines (XLODBC and 1) as below, followed by your ODBC connection string on the third line and your query on the fourth line (all on one line), e.g.:
XLODBC
1
Driver={Microsoft ODBC for Oracle};server=DB;uid=scott;pwd=tiger;
SELECT COUNT(1) n FROM emp
Then, if you open the file by double-clicking it, it will open in Excel and populate the worksheet with the results of the query.

Make a file SOMEFILENAME.udl then double click on it and set it up as an ODBC connection object, username, pwd, target server

You can use the "Test Connection" feature after creating the ODBC connection through Control Panel > Administrative Tools > Data Sources.
To test a SQL command itself you could try:
http://www.sqledit.com/odbc/runner.html
http://www.sqledit.com/sqlrun.zip
Or (perhaps easier and more useful in the long run) you can make a test ASP.NET or PHP page in a couple minutes to run SQL statement yourself through IIS.

For ad hoc queries, the ODBC Test utility is pretty handy. Its design and interface is more oriented toward testing various parts of the ODBC API. But it works quite nicely for running queries and showing the output. It is part of the Microsoft Data Access Components.
To run a query, you can click the connect button (or use ctrl-F), choose a data source, type a query, then ctrl-E to execute it and ctrl-R to display the results (e.g., if it is a SELECT or something that returns a cursor).

a simple way is:
create a fake "*.UDL" file on desktop
(UDL files are described here:
https://msdn.microsoft.com/en-us/library/e38h511e(v=vs.71).aspx.
in case you can also customized it as explained there. )

It's been a while but since I precisely have the answer to the question, I'll share it and maybe someone will benefit from it.
Jaime de Los Hoyos wrote a very nice program to precisely do that: ODBC Query Tool.
Unfortunately, Jaime's website is defunct but you can still find the program and its source code at this location:
https://sourceforge.net/projects/odbc-query-tool/files/latest_release/
The program is GUI based and consists of a single executable file, no need to install anything on the machine.
Jaime's profile : https://stackoverflow.com/users/878998/jaime-de-los-hoyos-m
Jaime's posts on a forum talking about his program : https://forum.powerbasic.com/forum/user-to-user-discussions/source-code/48266-odbc-query-tool-retrieve-information-from-any-database-easily

Related

How to connect R to SQL Azure?

I have two databases in Azure and each has 5 tables. I can perform data wrangling inside Azure using Kusto but I would rather prefer using RStudio. I wish to connect R with Azure such that I can run a script in R and return results without importing the actual datasets.
Please help, where do I start? I have zero knowledge of such connections.
Thank you in advance.
Assuming you have already installed R and RStudio. Please follow below steps:
Open ODBC Data Source through Start Window and Add a User Data Source under 'User DSN' as below. Follow through the next buttons until finish and test the connections.
Go to RStudio and create new connection, you should see the Data Source added in above step. You should see the connection and table listed under Azure Sql Database that you connected with.
Run the query like below in Console:
dbGetQuery(con, "SELECT * from dbo.xxxx")
You should be able to see the result set accordingly. You can play with queries in the way you want.

Unable to create query COPY PostgreSQL PQSQL driver

Well the thing is that when the program execute the query to copy a table to a file .CSV. Qt show me the next error.
"ERROR: syntax error at end of input
LINE 1: EXECUTE
Here are the code of the export action:
QSqlQuery qry;
qry.prepare("copy inventory to './inventory.csv'");
if(qry.exec()){
qDebug()<<"Succes";
}else{
qDebug()<<qry.lastError().text();
}
The version of qt is 5.4, used postgresql 9.3 and driver PQSQL working fine just can execute another's query very well like select.
Thanks.
You mentioned that you're using Qt's SQL interface and its PostgreSQL driver.
While Qt's PostgreSQL driver is built on top of PostgreSQL's standard client library libpq, as far as I can tell it does not offer support for lots of the functionality of libpq. In particular, there appears to be no way to access support for the COPY protocol, nor for LISTENing for asynchronous notifications.
You will have to:
libpq directly to COPY ... FROM STDIN
or use regular INSERT statements via Qt; or
Transfer the CSV input to the server, then use COPY ... FROM '/path/on/server' to read the input from a file on the server that the PostgreSQL database is running on, readable by the user the PostgreSQL database runs as.
(You could also submit a patch to Qt to add support for the COPY protocol, which shouldn't be too hard to implement, but is perhaps not the best choice if you're asking this.)
Using COPY needs superuser rights . Do not confuse with \COPY of
PostgreSQL
COPY TO requires absolute path to the output file. If 1st point is
considered, try removing the ./ in your output file name
You can refer to related posts:
post1
and
post2

DynamoDB client in local with UI like PHPMyAdmin

I am creating web service in zend framework which uses DynamoDB. So I installed DynamoDB in local. But it's not easy to use. Even for inserting data and update any data for testing for purpose I have to write a script.
Is there any DynamoDB client available for MAC ? In which we can insert/update/delete data from UI.
EDIT
Doubts
1) Do I have to run a SQL to see table data? I thought there would be GUI for this.
2) I am not able to use where clause in SQL. What if I want to see one or two records from all? Is there a way to use conditions in this?
3) All fields of a row is not visible and I am not able to scroll it horizontally ?
YES! I've finally found a solution after struggling with this myself:
Run your local dynamodb jar with the following command java -jar DynamoDBLocal.jar -dbPath . [this will create a file in whatever directory the Dynamo jar is located in].
Download SQLite Database Browser and extract/install it.
Start SQLite Database Browser
Navigate to "Open Database" from the file menu
Navigate to the directory from 1. Select the file [in this case, ****_us-east-1]
You should then see the database contents!!
Hope this helps - it's been frustrating me no end!
!! EDIT !! - in response to original question edit.
Doubts
1) Do I have to run a SQL to see table data? I thought there would be
GUI for this.
2) I am not able to use where clause in SQL. What if I want to see one
or two records from all? Is there a way to use conditions in this?
3) All fields of a row is not visible and I am not able to scroll it
horizontally ?
Yes - you can do a simple "select" statement, for instance in my examples: "SELECT * FROM tweet_item" returns me the following screenshot:
Seemingly inadvertanyl - whilst I couldn't get the direct SELECT * FROM XX WHERE XX to work, the like statement does. For instance SELECT * FROM tweet_item where tweet_item.hashKey like "%425665354447462400%" returns me the tweet with tweet_id [my hashKey] of 425665354447462400:
Strange - I seem to be able to scroll quite happily [although it is Windows not Mac]. It also automatically tries to re-size the outer frame, too.
I ran into this problem and found a relatively new solution : https://github.com/aaronshaf/dynamodb-admin
It has provision for GET/POST/PUT/DELETE.
Although its a paid product, which is a bummer, RazorSQL now supports DynamoDB as well, and does let you change the AWS endpoint to point to a local installation.
The mac version (with a free trial) is available here:
http://razorsql.com/download_mac.html
Here is a very useful ui tool https://github.com/YoyaTeam/dynamodb-manager,It supports almost all data operations。
For Eclipse users:
Amazon provides AWS Toolkit for Eclipse IDE. It can view local and cloud databases. Also if you are using different regions, it has ability to choose from different regions.
You can create attributes, add keys etc..
For installation follow this link: http://docs.aws.amazon.com/toolkit-for-eclipse/v1/user-guide/getting-started.html
Dynobase is new DynamoDB GUI Client which also lets you browse and manipulate local DynamoDB instances: https://dynobase.dev/dynamodb-local-admin-gui/
Unfortunately, it's paid but there's free 7-days trial, works on Mac, Windows and Linux: https://dynobase.dev/

Connecting my ruby program to an SQLite database using RubyMine

I'm writing a Ruby program to manage courses run at a university, the modules associated with those courses, and the students registered on the courses and modules. I'm using RubyMine to write the program, and I now want to connect what I've written so far to an SQLite database to check that it works as I expect. But I'm not too sure how to do this in RubyMine.
I've opened the database tool window, and it says "No data sources configured", as well as having two "loading" messages at the top of the window.
If I right click on the window, I get a few options, one of which says "Add data source", from which I can add a "DB data source", or a "DDL data source".
I've only ever written one Ruby program before (about 10 months to a year ago), and I used the command line to write it then, also using the command line to create and edit the SQLite database. How can I set up an SQLite database to run with my program from RubyMine?
Also, is there a huge difference between SQLite and SQLite 3? Are there reasons for using one over the other? Which one would people recommend I use?
EDIT 24/08/2012 at 13:50
I tried selecting the option "Run rake tast" from the 'Tools' menu in RubyMine- it then asked me to enter task name or its part, I tried entering "db:migrate", but it said "no matches found".
Any idea what I should do instead?
Please refer to the documentation, RubyMine connects to the database via the JDBC driver. Most likely you want to use SQLite 3 version, as it's the current version at the moment. Check this video for the overview of the Data Sources features.
To connect your program to the database you don't need JDBC driver, it can be done with the sqlite3-ruby gem.
You can also consider some ORM, like Rails ActiveRecord or DataMapper, or Sequel.

How to Import MicroSoft Access Database (mdb) into SQL Express File using SQLCMD?

For some reason neither SQL managment studio nor import and export wizard works on my friends network due to some security policy
i asked a question about OSQL two days ago and StackOverflow guys told me it is going to be obselete and that i should use SQLCMD instead.
now i am stuck with this screen and cant do anything :(
to cut long things short my question is very precise:
using SQLCMD..
1-need to import and export command from AND to MDB/MDF
2-need attach / detach commands
mokokamello
below is how to attach new database and make sure your database is attached
you also will need to check these links
http://msdn.microsoft.com/en-us/library/ms165673.aspx
http://msdn.microsoft.com/en-us/library/ms188031.aspx
AND THE MOST IMPORTANT LINK
http://support.microsoft.com/kb/224071
if you want to dettach
sp_detach_db DatabaseName
Go
SQLCMD allows you to enter Transact-SQL statements to the chosen server.
The T-SQL command for connecting to an external data source is OPENDATASOURCE
More info here:
You should be able to construct a series of queries using this in order to pull in, and export the data you are working with.
The SProc to detatch a database is sp_detach_db, and to attach sp_attach_db
More information here, here and here

Resources