Connecting my ruby program to an SQLite database using RubyMine - sqlite

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.

Related

Access 2016 - cannot add new links to External Machine Data Source - ODBC database tables

I'm running Access 2016 (64 bit) on Windows 10 and only recently noticed this problem. I have several functioning databases that already have a number of working links to tables on two or more External Machine Data Sources. When attempting to add a new link I go through the usual procedure of clicking on "External Data", "ODBC Database" select "Link to the data source by creating a linked table" then go on to select the desired Machine Data Source; at this point the list of available tables comes up and everything seems fine. The problem arises when I select a new table (one I do not already have a link to), click the "Save password" box then proceed: I ultimately end up with an "ODBC--call failed" error that specifies "Error while executing the query (#1)". The first thing I would normally suspect would be a problem with the ODBC driver configuration but all my pre-existing external links continue to function just fine; I only encounter problems when attempting to add new links. How can I find out more about the query mentioned in the error message? Is this "query #1" a universal thing or could it be specific to the way my particular ODBC driver config is set up?

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

putting Navicat files in git?

I'm looking at switching from MySQL Workbench to Navicat because we're using MariaDB and the incompatibilities are starting to annoy me.
I'm working through the issues of getting Navicat to run on Centos under WINE but assume I will succeed (edit: this failed. The "linux" version requires WINE. Navicat will sort of run with a bit of hacking, but critical features rely on MS-Windows/WINE)
How do I get Navicat to work with git (or any other source code control)? Workbench is sufficiently primitive that file changes either get picked up automatically or completely ignored (almost always a dialog "file on disk has changed, reload?")
Specific problems:
when adding new query files Navicat only seems to rescan the folder when I add a new query. Is there a smart way to do that? (edit: no. You can manually refresh one file at a time by right clicking)
model and query files are buried deep in the WINE tree. Can I relocate them or or symlinks work? I'd rather keep all the DB-related code in one repo, rather than having a special Navicat repo. (edit: yes, but the explanation of how to do so is lengthy)
is there a way to merge a model file if more than one person has changed it? Workbench can't do this but I'd really like the feature. (edit: no, never. Merge the schema SQL files instead)
Also, bonus question: can we make multiple edits using Navicat other than repeated use of the GUI? If I want to change (say) a bunch of columns from VARCHAR(255) to CHAR(20) I'd normally script that in SQL but Navicat models don't do reverse engineering, only "delete the table from the model then re-import it" so there doesn't seem to be a non-tedious way to do that. (edit: no, but they might look at it in the future)
Final edit: I used the Navicat forums and the team were very helpful, but fundamentally Navicat is Windows software and the 64-bit purists behind Centos will never support WINE. For most Linux users this is not a problem, but I work with Centos enthusiasts and have long since lost the argument about which distro to use.
To the 1st question, you can sync it in different ways with a remote database/folder, when you are managing the database with Navicat, just right-click in your current connection and press "refresh", so you will be updated with the server changes. You also can do it with a programmed task.
Another matter is, why would you want to run navicat from wine when it has a native linux version? (I hope that answers the 2nd question)
For the 3rd question note that Navicat has an internal utility to sync data between servers, so you don't need git at all, or at most, you can automate the structure exportation and then sync it with a git repository (in form of a .sql file)
IMHO you need to review your concepts about mariadb and navicat, both are quite flexible and offer several ways to do such things you propose, like sync the data and they also allow to insert git in the workflow, just review your strategy and try to apply some new perspective with the available features.

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/

Simplest Way to Test ODBC on WIndows

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

Resources