1. Deactivate the virtualenv if there is.
pyenv deactivate
2. Install the required libraries.
sudo apt-get install libpq-dev python-dev
3. Install PostgreSQL.
sudo apt-get install postgresql postgresql-contrib
1. Deactivate the virtualenv if there is.
pyenv deactivate
2. Install the required libraries.
sudo apt-get install libpq-dev python-dev
3. Install PostgreSQL.
sudo apt-get install postgresql postgresql-contrib
Previously we talked about setting up some custom command in a Django project.
I would like to run the custom command in a regular interval. I could use Linux cronjob but it’s hard to manage and check the run history. It would be great if i could setup and manage these scheduled commands on the Django web portal.
django-chronograph, written by wnielson, is a Python Package which allows us to schedule any django-admin command through the web interface. It works well with the UTC timezone but if you have set the TIME_ZONE in your Django project setting.py, there would be time discrepancy.
For more detail about the bug, you can refer to the Issue #36 – Job doesn’t follow the Django’s TIME_ZONE setting.
Continue reading Django – Schedule django-admin command using django-chronograph
There is a timezone configuration on PostgreSQL server. If you want to change the default globally, you can edit the postgresql.conf. On Ubuntu, it is located at
# - Locale and Formatting - datestyle = 'iso, mdy' #intervalstyle = 'postgres' #timezone = 'Hongkong' timezone = 'UTC'
We could also tweak the timezone only in your current PostgreSQL session.
1. Get the current timezone.
SELECT current_setting('TIMEZONE');
Next: Drupal 7 – Create a Datetime field in hook_schema() @ 1
If your custom module requires an additional table in the Drupal database, you have to create the .install file and define the schema inside it. In Drupal 7, the datetime field is no longer support by the Drupal Schema API. If you want to create a datetime field, you have to use the mysql_type or pgsql_type. Here is an example.
Continue reading Drupal 7 – Create a Datetime field in hook_schema() @ 1
Recently, there is a performance issue on the application which i am supporting and i find that the bottleneck is related to the SQL query speed. Therefore, my SA suggests me to add an index on the table to increase the query speed.
But before i could add the index, i have to find out the SQL which runs slow. In PostgreSQL, you can query the recent SQLs by the pg_stat_get_backend_activity() function. Here shows you an example. Continue reading PostgreSQL – Check Running SQLs
I found a good article which the author shows you how to select random records from table among different kind of databases.
Here are the example for SQLite, MySQL and PostgreSQL.
Continue reading SQL – Select Random Records From Table
PostgreSQL version: 8.3
By default, the PostgreSQL database files is located at /var/lib/pgsql/data. Initialize the database can be done by the following command.
Continue reading PostgreSQL – Initialize Database At Different Location
The current available postgresql-server package in CentOS Yum Repository is 8.1.18. But my application needs postgresql-server 8.3. Luckily, PostgreSQL provides its own repository for upgrade. So Fedora, Redhat and CentOS users can upgrade by the following steps.
Continue reading PostgreSQL – Upgrade version from PostgreSQL Yum Repository
Operating System: Gentoo Linux
To check your PostgreSQL version, simple enter the login to psql
psql -U <username> -d <dbname>
Continue reading PostgreSQL – Check Your PostgreSQL Version
OS: Ubuntu 8.04
PostgreSQL: 8.3
By default, PostgreSQL database connection only listens to localhost. If you want to connect to a PostgreSQL database with another machine, 2 files needs to be modified.
Continue reading PostgreSQL – Allow Database Connection From Remote Machine