Eclipse plugin for psql/PostgreSQL code? - eclipse

Do you have recommendations for a good PostgreSQL editor plugin for Eclipse?
The PostgreSQL code I have isn't very complex. However I'd like to edit it with syntax-coloring, decent auto-identation, code completion, etc., and it would be sweet to be able to send blocks or entire files to a jdbc connection and get the results. Up until now, I have edited my .sql files with Emacs, and try things by copying/pasting segments into a psql terminal I have next to Emacs. Some of my code uses the psql primitives such as \set var value etc. For example:
\set t mytable
drop table if exists :t;
create table :t (...);
However I would be happy to eliminate this and refactor the code to be proper PL/pgSQL functions. Or perhaps better, implement the dependency and procedural logic in Java and issue the sql queries via JDBC. I still need to edit the sql files and try bits and pieces of them during development.
I tried the "official" Data Tools Platform (http://eclipse.org/datatools/) and configured it to use my localhost:5432 (which in fact is a port-forward via SSH to the actual PostgreSQL server that I'm using). However, connecting to the DB hangs for several minutes (Eclipse doesn't even refresh the screen). In general it feels quite heavy/slow
and I'm always afraid of if hanging without ability to interrupt it (it happened a few times and the only solution is to kill Eclipse; as you probably know, killing Eclipse isn't good as it's very hard/impossible to recover unsaved files).
The other plugin I tried is Toby's PL/SQL editor (https://sourceforge.net/projects/plsqleditor/), which seems very nice and promising, except the last signs of life on the sourceforge forums appear to be around 2007. Also I couldn't configure it to use the postgresql-9.0-801.jdbc4.jar that I have, and so I am unable to connect to my DB.
Any suggestions gladly appreciated.

A free Eclipse plugin for Oracle and PostgreSQL can be found at http://www.toadworld.com/products/toad-extension-for-eclipse/default.aspx
The plugin is in development.

Related

Import/Export Dialog Disappeared in pgAdmin

I use a PostgreSQL database on my local computer. I always import csv files via right-click to the relevant table and choosing the Import/Export Dialog. However, when I opened the pgadmin last time, there was no import/export option in the options. I do not know what happened to it. I, once, took a backup of files and use this backup file to migrate the database to another version of Postgres. I am not sure but I want to ask might one of the options that I selected or did not select cause this trouble?
I also tried to go in an alternative way by using copy from 'C://path/data.csv method and it did not work. then I tried \copy from 'C://path/data.csv but it did not even recognize the \ symbol and gave an error.
I wonder what happened to Postgres or pgadmin and how can I find a solution to import my data to the Postgres database?
I had the same issue, looked everywhere but nothing came up on WHY this happened or HOW to fix it.
RESOLUTION: I was able to resolve this by downloading the latest version of pgadmin4.
After downloading, the Import/Export dialog reappeared.
Hope this helps you too!
Import/Export Dialog - Resolved

PostGIS & QGIS - PostGIS extension not accessible?

I am having an odd problem with PostGreSQL/PostGIS on a Windows 10 machine.
I have successfully installed PostGIS many times without issue over the years, most recently last week on a Windows 10 machine at work. I typically use QGIS as my client, so have a fair idea how these things need to be configured and operated.
Over the weekend, I downloaded the latest PostGres 11 installer with Stackbuilder, and installed PostGres & PostGIS. pgAdmin4 seems to show everything is as it should be, and the sample 'postgis_23_sample' database is present and correct.
However, using QGIS DB Manager, when I try to connect to the database (on port 5432), whilst I can see the sample database and public schema, I cannot create a new table with geometry, or load any data (e.g. a simple shapefile) into the database. The error message tells me that the 'addGeometryColumn' function does not exist. I checked that the PostGIS extension is installed - which it is. (I ran 'CREATE EXTENSION postgis' again to confirm this.)
So, I went back to pgAdmin, and tried creating a table with geometry via SQL, but got the same error: Creating a table without geometry works just fine. As soon as I try to create a geometry column, I get the error. It seems to me that the PostGIS extension is somehow not being 'found' by PostGres.
I have uninstalled and reinstalled various combinations of PostGres, PostGIS and QGIS over the weekend - but get the same error. I created a new Windows account, and tried installing the stack there: same thing happened.
I also tried uninstalling everything and then installing the 'Portable GIS' stack by Astun. These are much older versions of QGIS and PostGIS, but in theory the installer configures them all to work together. (That, at least, has been my past experience of using Portable GIS at work.) In this instance, I got the same error about the missing AddGeometryColumn function.
I am wondering if the various installs of PostGIS, QGIS and other tools over the last year or so have left some stubborn configuration entries (maybe in the registry?) that uninstallers have not been able to remove. Could something like that be upsetting my recent PostGres insatllations? It feels as though something is preventing DB clients from locating the PostGIS services on the assigned port. Having said that, PostGres iteslef seems to be working fine, so maybe that is nonsense.
In any case, if anyone has any ideas how I can begin to debug and fix this, I would be hugely grateful. (In the meantime, I am about to try the OSGeoLive Lubuntu VM, which at least will enable me to get some proper work done - I hope.)
Thank you...

Connect PostgreSQL to HammerDB

As the title says, I want to connect PostgreSQL (I'm using the 9.6 x86 version) to HammerDB, an open source database load testing and benchmarking tool (I'm interested in the TPC-C Benchmark).
The thing is that I can do this connection by using MS SQL Server (2014), because it is relatively easy. However, I'm not used to use PostgreSQL. When I try to create Virtual Users on HammerDB (that's the 1st step to do, then you should be able to perform the transactions) I get the following error:
Error in Virtual User 1: Failed to load Pgtcl - Postgres Library Error
I did some research about this, and I found that, and I quote "PostgreSQL is VERY particular about the libraries in its PATH - they have to be the right ones and ONLY the right ones any other configuration will cause errors".
The problem is that HammerDB couldn't load library libpgtcl.dll. There they mention that to fix the problem, one should check that the PostgreSQL bin directory has been added to the path during install, but at this point I'm totally lost and I don't know what to do. I simply canĀ“t get what they mean and how to do it.
I hope at least one of you could help me. I would appreciate it a lot.
Sorry in advance for my mistakes in English, I'm a Spanish speaker.
Well, I have solved the problem, and it is very simple.
Everything is about Setting Windows PATH for PostgreSQL, and I found that here.
Open my Computer ==>
right click inside my computer and select properties ==>
Click on Advanced System Settings ==>
Environment Variables ==>
from the System Variables box select "PATH" ==>
Edit... ==>
Then add this at the end of whatever you find their
;C:\PostgreSQL\9.2\bin; C:\PostgreSQL\9.2\lib
after that continue to click OK
That's all. So this is what you should do if you are having trouble when trying to connect PostgreSQL to HammerDB, and in general, when trying to use PostgreSQL tools.

postgres attaching a process

How do we attach a sql query such as join query to an existing gdb process in eclipse? Whenever I try to fork the given process using debug configurations in eclipse, which is a shared library , I am getting the following error:
No source available for "__kernel_vsyscall() at 0xb729c424"
Also, whenever I set break points in a specific program in eclipse, control goes to main.c and finally the process never comes back to the actual program.
Is there any way that the process be constrained only to my specific program?
how do we attach a sql query such as join query to an existing gdb process in eclipse
Um, what?
Are you attempting to debug a PostgreSQL server backend? If so, see the PostgreSQL wiki page that provides lots of details on the topic.
Whenever I try to fork the given process using debug configurations in eclipse, which is a shared library
What is a shared library? Eclipse isn't. PostgreSQL isn't. So what's the shared library here?
Are you trying to debug a PostgreSQL extension? If so, see the above link for details on attaching to a PostgreSQL server backend.
No source available for "__kernel_vsyscall() at 0xb729c424"
That's normal. It's just telling you that there's no source code on record for the __kernel_vsyscall call that's the entrypoint into syscalls in linux-gate.so via glibc when using sysenter.
The stack below it should be more informative. Get a backtrace, then look at the lower stack frames.
See:
What is __kernel_vsyscall?
Having trouble finding the method __kernel_vsyscall within the Linux kernel
http://www.trilithium.com/johan/2005/08/linux-gate/
Your "also" is really a separate question, and it's pretty hard to answer it usefully with the total lack of information provided. Try posting a new, more detailed question on just that topic. Specify how you compiled the program, set it up for debugging, how you're running it, where you're trying to set breakpoints, etc.

A good development environment setup for Web2Py

Have been trying out Web2Py for a couple of days now and I decided it to be a keeper. But there is one thing that concerns me a lot and that might be a showstopper in the end. I need a nice development environment & setup I can trust and be productive with. Coming from the MS Visual Studio world I'm looking for something with good autocomplete / intellisense + functions for versioning and deployment.
I did some attempts to edit my code in Eclipse but it needs additional setup to run with autocomplete, and for debugging I dont know if it's possible. (Noticed there was a Django project template in Eclipse which is a bit tempting I must say.)
Wing Ide has a instruction on how to get web2py up and running and I am up to testing that one. Not free, but very cheap compared to much in the Windows world.
I also want a good versioning (hg) setup, and preferably a semi-automatic FTP-deployment-method.
What IDE do Web2Py developers use, and how do your setup look like?
A complete setup script for a project in a good IDE would be awesome! (Just like the installation is, one click to get it running 100%).
Pycharm looks good, perhaps that one can add web2py support http://youtrack.jetbrains.net/issue/PY-1648
Thanks a lot!
OS: Windows 7/Windows XP
IDE: NetBeans
Version control: TortoiseHg/NetBeans
Debugger: winpdb
Shell: IPython
Publish: WinSCP/PuTTY/TortoiseHg
Scripts
Once I create a new project in web2py I add a few scripts to my main app folder:
web2py\applications\myapp\DebugWinpdb.bat:
C:\Python25\Scripts\winpdb.bat ..\..\web2py.py -i 127.0.0.1 -p8000 -mypassword
web2py\applications\myapp\DebugShell.bat:
C:\Python25\Scripts\winpdb.bat ..\..\web2py.py -S myapp -M
web2py\applications\myapp\Shell.bat:
python ..\..\web2py.py -S myapp -M
IDE
As others have stated you need to do some extra stuff to get autocomplete/intellisense for web2py no matter what IDE you use.
For me NetBeans was a good compromise between does-everything-if-only-you-can-figure-out-how (Eclipse/PyDev) and does-the-basics-but-few-extras (PyScripter).
NetBeans Setup (Project Properties):
Python Category
Python Platform: Python 2.x (default is Jython)
Run Category
Main Module: web2py.py
Application Arguments: -i 127.0.0.1 -p 8000 -a mypassword
NetBeans Pros:
Tight Mercurial integration
Highlights which lines have been added, changed, or deleted in your source file as you edit it
Selective rollback of individual changes you've made since your last commit
One of the nicest visual diff viewers I have used
Python PEP8 style hints (fully customizable)
Name "foo" is not a valid class name according to your code style (CapitalizedWords)
Name "Bar" is not a valid function name according to your code style (lowercase_with_underscores)
Auto-format hotkey (corrects spacing around operators, etc)
Navigation within source file
semantically indexes current source file
organizes alphabetically by type (Class, method, attribute, etc)
makes even enormous style sheets manageable
NetBeans Cons:
Integrated Debugger doesn't work with web2py (that one really hurts)
Long startup time (but acceptably snappy for me once up and running)
Version Control
I use and highly recommend Mercurial for source control. As mentioned earlier, NetBeans has great support for Mercurial but there are some things I'd just rather do in TortoiseHg.
TortoiseHg Pros:
Shell overlay icons
Repository Explorer
view repos history with graphical display of branching/merging
one stop shop for Incoming, Outgoing, Push, Pull, Update, etc with button for Commit tool
Commit tool
Hunk Selection: cherry pick changes from within a file for more focused Commits
Add, Remove, Diff, Revert, Move, Remove, Forget
TortoiseHg Cons:
No easy way to drop directly into a command line
Bug that regularly prevents files from being removed during commit (waits indef for a lock to be released; running hg addremove from command line is a reliable workaround)
Publishing
I use a combination of WinSCP (for browsing), PuTTY (for terminal commands), and TortoiseHg (for push/pull of my repos) to work with my shared hosting account on Webfaction.
The first thing I do is set up public/private key encryption. If you are having trouble getting this set up between Windows and Linux, try these instructions from Andre Molnar. Short story is you need to generate your private key using ssh-keygen on Linux, copy it down to your Windows machine using WinSCP, then convert it for use with WinSCP and PuTTY.
Then add the following lines to your global mercurial.ini file:
[ui]
ssh = "C:\Program Files\TortoiseHg\TortoisePlink.exe" -ssh -2 -i "c:\path\to\your\privatekey.ppk"
Even if you have to connect to multiple servers, you need only copy your public key to each of the different servers. You'll also want to let WinSCP and PuTTY know where your private key is located, but those are fairly easy to figure out.
Try the new web2py admin interface in trunk. It has a web based mercurial interface and a google deploy interface.
In web2py you can edit applications/admin/models/0.py and set
TEXT_EDITOR = 'amy'
And you will get the web based Amy editor with autocompletion. It is not default because because it does not work with some browsers and because autocompletion is not as good as eclipse. It may work for you.
You can use web2py with Eclipse but you need a minor workaround to let Eclipse know about the web2py environment. It is explained here.
I know other users have used other IDEs with web2py, for example WinIDE and pyCharm. I suggest you ask on the web2py mailing list where people are very helpful.
I'm pretty sure that the 'one-click setup script' to do all that you are looking for does not exist (at the moment). But don't be put off - you can achieve a nice development environment to suit your needs and there are lots of choices.
Although I develop on Windows, I like the setup I have as it's more of a 'Unixy' way of thinking whereby I have a number of tools each doing a specific task. Once you get a workflow setup you can be very productive - although I realise it may look a bit confusing initially coming from a Visual Studio world.
Below I outline what I've settled on. I'm sure others will have their own recommendations. Pick the options you like best.
(There should be hyperlinks to useful software below but I don't have enough reputation to include more than 1 link...)
For developing on Windows I'm enjoying using Pyscripter. It's free, fast (compared to Aptana / Eclipse / Netbeans etc) and has some nice features (dark theme, integrated python console and code explorer to name a few).
To get code completion / intellisense to work for web2py you need to add some code to your model / controller files because of the way web2py works. There are some instructions in this discussion topic on the web2py group.
web2py has a great error ticketing system built in (see the web2py book chapter 3). For more comprehensive debugging, pydb seems to be the way to go. Just put the code below as a breakpoint:
import pydb
pydb.debugger()
and it'll take you to the debugger.
I use TortoiseHg for Mercurial integration and it works wonderfully. Combine that with winscp and you can deploy easily.
Caveats: I work in OS X, and do most of my coding in BBEdit.
That said, I've used both Wing and Komodo IDE for web2py debugging, and they've both worked quite well for me. I haven't tried NetBeans in a while now; when I did the Python support seemed a little rough around the edges. And I've never had the time or patience to come up to speed with Eclipse; it's filed in my mental file cabinet with Emacs, no doubt unjustly to Eclipse and/or Emacs.
(And I'll echo mdipierro's recommendation to try the web2py mailing list; it's really indispensable--one of web2py's strongest points.)
Have you considered using fewer tools? Both Python and web2py don't require a whole lot of code to get a lot accomplished. web2py only adds 10 or 15 new function calls (besides the HTML helpers and validators). You might find that Eclipse and other IDEs actually get in the way. Setting up new apps in web2py is simple through the admin system. Since the new app scaffolding copies the welcome app, you can customize new app setup by editing the welcome app. With Mercurial (or Git, Subversion or Bazaar) you can set up a server on your machine or with one of the public sites and either push or pull updates to your production server. Keep it simple, I say.
we are using web2py framework for all our web application needs and this is our setup :
OS - Ubuntu up-to-date
IDE - Aptana Studio 3.0 with pyDev
Version Control - git
Python 2.7
Browser for developing phase : Chrome
I've found the Wing IDE debugger to be very useful. It's a powerful debugger across the board, and also can be configured to do remote debugging, which is really important when you are running web2py on a no-GUI remote machine (e.g. at Amazon Web Services).