Skip to main content

Posts

This code demonstrates how to update Postgress Database Table in Bulk

More about Postgres and Python can be found here. If you have any question please let me know.
Recent posts

Connect Jupyter Notebook Pandas to Postgres

First install Python library Psycopg2 to connect to PostgreSQL:

!pip install psycopg2

Now import the necessary libraries:

import pandas as pd
import psycopg2 as pg
import pandas.io.sql as psql

Connect to the DB Server:

conn = pg.connect("postgres://username:password@server:port/dbname")

Execute a Query:
df = pd.read_sql('select* from table_name', conn)
df.head()

Google Analytics on Refined Wiki Mobile Theme

Tracking mobile users on Confluence while using Refinedwiki mobile theme is not possible or straightforward using theme configuration. I found a work around that will track users on Google Analytics smoothly. Please follow the below steps:


Create a js file, call is analytics.js with the analytics script code, it should look something similar to the below:
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-XXXXXX', 'auto');
  ga('set', 'userId',AJS.Data.get("remote-user")); // Set the user ID using signed-in user_id. 
  ga('send', 'pageview');Save your script on confluence server confluenceInstallationDirectory/…

linux Server out of Space

You could find your VPS out of space all the sudden especially if you are enabling logging for your website or web apps. First you need to know which directory is taking most of the size, then you can eliminate the problem or ask to increase disk place:

Go to the root of your vps by typing on ur shell:# cd /Run: #sudo du -h --max-depth=1Note which directories are using a lot of disk space.cd into one of the big directories.Run #ls -l to see which files are using a lot of space. Delete any you don't need.

IDLE subprocess didn't make connection Python 3.7

After installing Python on Windows 10. When trying to open IDLE, Python's IDE, you might get a  message saying that "IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection".

To solve this issue just run IDLE as an Administrator, by right click on the IDLE icon and click Run as administrator. See Photo below:


ERROR: cross-database references are not implemented

You face this error while trying to query two tables from difference databases in Postgres, as Postgress is unlike SQL Server, you can't join two tables from different databases.
Instead you may have One Database with Two different Schemas.
Schemas group your data tables separately and give you the flexibility to query and join tables from across schemas in the same Database.

So if you have DB1 and DB2, you need to move the tables in DB2 to DB1 but in a new schema.

If you are using the public schema in DB2 you need to change the name:
alterschemapublic rename to new_schema_name;createschemapublic; Now Backup your Schema:

$ pg_dump --format custom --file "my_backup" --schema "new_schema_name" "db2"$ pg_restore --dbname "db1" "my_backup"
Your Done. If you have any question please let me know.



Windows font cache service status Stopping

I was trying to install a language package to my MSOffice 2013 and was stuck with an error:

Error 1920. Service 'Windows Font Cache Service' (FontCache) Failed to start...

In windows search look for services, then check the below service

Windows FontCache Service

Most likely the service is stopped or stopping or disabled. If you can't start the service what you need to do is install the service again, if you are running windows 10, 7 or 8 this website will help you:

http://batcmd.com/windows/10/services/fontcache/

Restore Default Startup Type for Windows Font Cache Service, by downloading the proper restore file to your computer. Run the restore file, restart your machine. All is done. You may install the Language package smoothly now.

Good Luck!