Skip to main content

Posts

Showing posts with the label postgres

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()

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:   alter schema public rename to new_schema_name ; create schema public ;   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.

Datatables Server Side Processing using Coldfusion

Datatables Server Side Processing using Coldfusion Code: Coldfusion Server Side For Datatables Environment: Datatables 1.10.16, Lucee 5.x, Postgres 9.6 Issue Date: 04/10/2017 Notes: There is no warranty that the code will work on a different environment or different version. You may create the DB table using the postgres.sql script included. This project was tested and fully functioning. Features: Datatables query paging Case Insensitive search filter to all query results. Sort by all fields including date. This repository does not include all Datatables features. In the code I'm only using datatables.js, but you may extend the features.  Repository is available on github .