Search This Blog

18 December 2010

Migrate Data from Access 97 to PostgreSQL

To migrate data from Access to PostgreSQL, so many tools are available online. I did try to migrate data with few tools, but no success. I encounter issues with the tables which has boolean fields and with the tables in which access date() and time() function are being used to set default value of a column.

The best way to migrate data from Access to PostgreSQL database, I found is through PostgreSQL ODBC driver. To check how to install and setup PostgreSQL ODBC driver go to Install & Setup PostgreSQL ODBC Driver . Once finished with installation and setup of PostgreSQL ODBC driver, you are ready to migrate the data.

How to migrate data from Access to PostgreSQL using PostgreSQL ODBC?
  • Open the access database, select the table, then click on file, Save As/Export, a “Save As” popup will appear, select “To an external file or database” radio button and click ok.
  • Then in the new popup for “Save as type” select “ODBC database”.
  • An Export window will appear, change the table name if required, or just click ok.
  • “Select Data Source” window will appear, select your PostgreSQL DSN, that you have created as mentioned above. And click ok.
  • Selected table will get exported to your postgres database.

15 December 2010

Install & Setup PostgreSQL ODBC Driver

Install PostgreSQL ODBC Driver
  • Download the latest PostgreSQL 32-bit ODBC Driver by choosing a mirror from http://wwwmaster.postgresql.org/download/mirrors-ftpand then navigating to the odbc/versions/msi/ folder. The current version is psqlodbc_08_03_0100.zip which was released Jan-22-2008.
  • Unzip psqlodbc_08_03_0100.zip
  • Run the psqlodbc.msi file
Setup PostgreSQL ODBC Driver
  • Click Start, Control Panel, then switch the control panel to “Classical View”, if it's already not in classical view or select "System and Security" category.
  • ODBC located inside Administrative Tools folder. Double click ODBC Data Sources. ODBC Data Source Administrator window displays.
  • Select File DSN tab and click Add button, select “PostgreSQL Unicode” from the popup opened.
  • Type in a name “pgCon” for "Create New Data Source” and Click Next
  • Then Click Finish and fill in relevant server, db, username and password.
  • Click the Connection button and uncheck Bools as char as shown in Manager Connection Page 1
  • Click the Page 2 button and check True is -1, and uncheck updateable cursors as shown ODBC Manager Connection Pg 2 and then click OK
  • A DSN (Data Source) with name “ pgCon ” is created and ready to use...

12 December 2010

How to Fix Corrupted Vista Profile?

Follow the following steps in order to recreate a user’s Vista profile when it gets corrupted.
  1. log into user’s workstation with your admin account
  2. Delete user’s local profile on C: drive under users folder
  3. Click on Start and run and type “Regedit”
  4. This will open Registry Editor Window
  5. Click on + sign besides HKEY_LOCAL_MACHINE
  6. Click on + sign besides SOFTWARE
  7. Click on + sign besides MICROSOFT
  8. Click on + sign besides WINDOWS NT
  9. Click on + sign besides CURRENT VERSION
  10. Click on + sign besides PROFILELIST and delete the SID number points to user name in Right side Pane
  11. Close Registry Editor window.
  12. Now RDP into the Server hosting that user’s profile.
  13. Go to Profiles folder and locate the user’s windows vista profile
  14. Rename this profile folder
  15. Ask the user to login and then logoff
  16. Now copy the user’s favorites and Desktop icons from the renamed profile folder to the new profile folder
  17. Ask user to login again and this will create a new profile for the user successfully.

11 December 2010

How to fix network printer dirver error for HP printers

  1. Delete the printer having printing problem from the printer window.
  2. Click on Start and Run and type in Regedit.
  3. This will open Registry editor window.
  4. Click on + sign besides HKEY_LOCAL_MACHINE
  5. Click on + sign besides SYSTEM
  6. Click on + sign besides CurrentControlSet
  7. Click on + sign besides Control
  8. Click on + sign besides Print
  9. Click on + sign besides Environments
  10. Click on + sign besides Windows NT x86
  11. Click on + sign besides Drivers
  12. Click on + sign besides Version-3
  13. Right click on the printer name and delete it
  14. Click on + sign besides Monitors and delete the folder for that printer
  15. Close the Registry Editor
  16. Go to System32 folder under C:\Windows\System32
  17. Click to open spool folder and click to open drivers folder
  18. Click to open w32x86 folder and click on 3 folder
  19. Under 3 folder delete all the instances for the printer giving problems
  20. Reboot computer and install the printer again
  21. It should work fine now.

29 November 2010

Important PSql commands

1. Command to connect to postgres
  • psql -h localhost -U postgres
2. Few general command that required when connected to Postges though shell
  • \h for help with SQL commands
  • \? for help on internal slash commands
  • \g or terminate with semicolon to execute query
  • \q to quit
3. Command to view the database assign to this user
  • \l to List databases
  • SELECT datname FROM pg_database;
4. Command to connect to a database
  • \c database-name  
5. Command to list tables in current database
  • \d to List tables in database
  • SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'
6. Command to describe a table structure
  • \d table-name

Important Linux commands for PostgreSQL

  • createdb
    createdb tmpdb -h localhost -U postgres

    Create a new PostgreSQL database 
  • createuser
    createuser ekta –s -h localhost -U postgres –P

    Create a new PostgreSQL user. Above command will create a new user ekta with the permission of superuser (-s) . And –P will prompt you for the password for new user. If we write this command without –P, it will create used which will not require password authentication
  • dropdb
    dropdb tmpdb -h localhost -U postgres

    Remove an existing PostgreSQL database
  • dropuser
    dropuser ekta -h localhost -U postgres

    Drops (removes) a PostgreSQL user
  • pg_dump
    pg_dump -h localhost -U postgres tmpdb > tmpdb.sql
    pg_dump --insert -h localhost -U postgres tmpdb > tmpdb.sql

    All above command are used to take database dump. It will extract a PostgreSQL database into a script file. --insert option is used to dump data as insert command.
  • pg_dumpall
    pg_ dumpall -h localhost -U postgres > tmpdb.sql

    Extract all PostgreSQL databases into a script file
  • psql
    psql -h localhost -U postgres

    Open PostgreSQL interactive terminal
  • vacuumdb
    vacuumdb tmpdb -h localhost -U postgres

    Clean and analyze a PostgreSQL database
Note : For information on above command check Linux help using man command, for example man pg_dump

17 November 2010

Windows Apache PHP and Postgres (WAPP Server)

BitNami WAPPStack includes Apache 2.2.16, PostgreSQL 9.0.0-1, PHP 5.2.14 and phpPgAdmin 4.2.2. phpPgAdmin is a web interface for administration of PostgreSQL. Steps to install and configure WAPP Server are given below,

Installation
  •  Download free copy of WAPP Server from http://bitnami.org/stack/wappstack
  •  Locate the downloaded file and double click the file to launch the installation.
  • The WAPP Setup Wizard will appear. Click Next.
  • At the Select Destination Location you can change the install directory. The default is C:\Program Files\BitNami WAPPStack. We will use the default directory. Click Next.
  • Then you will be asked for PostgreSQL postgres user password. Enter the Password. A Postgres user account will be created with user name “postgres” and the password you have entered. This information will be then used to connect with PostgreSQL server, through command prompt or through phpPgAdmin. Click Next
  • The default listening port for Apache is 80 and for PostgreSQL is 5432. If those ports are already in use by other applications, you will be prompted for alternate ports to use. Enter the alternate port if prompted. Click next
  • You are now ready to begin the installation, screen will appear. Click next
  • When installation is complete, “Completing the BitNami WAPP Stack Setup Wizard” page will appear. Click on Finish
  • You can now launch your browser with http://localhost/
Folder to create PHP files
  • The installation process will create several subfolders under the main installation directory i.e. C:\Program Files\BitNami WAPPStack
  • Create your PHP files in C:\Program Files\BitNami WAPPStack\apache2\htdocs
How to access phpPgAdmin
  • You can access your phpPgAdmin by opening a browser and typing http://127.0.0.1/phppgadmin. You will be asked for a username and password. As user name, use "administrator" and as password use the value specified during installation
  • Once you are connected with phpPgAdmin, to connect with default Postgres database, click on the Postgres on left bar, it will again ask for database user name and password. As the user name, use “postgres” and as password use the value specified during installation