Skip to content

Instantly share code, notes, and snippets.

@wynemo
Last active December 21, 2020 01:40
Show Gist options
  • Save wynemo/9d9b6a0f2401f4a437b1d6d400464142 to your computer and use it in GitHub Desktop.
Save wynemo/9d9b6a0f2401f4a437b1d6d400464142 to your computer and use it in GitHub Desktop.
psycopg2 python2.6.md

gcc

yum install gcc

install pg 10

sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-6-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install -y postgresql10-server
sudo service postgresql-10 initdb
sudo chkconfig postgresql-10 on
sudo service postgresql-10 start

#config pg 10 #change to postgres user balabala, createdb, create table, create new user, alter use password

su – postgres
pgsql

chang config

/var/lib/pgsql/10/data/pg_hba.conf   #peer -> md5
 service postgresql-10 restart

pip

curl https://bootstrap.pypa.io/2.6/get-pip.py > get-pip.py
python get-pip.py

header files

yum install python-devel
yum install postgresql10-devel

psycopg2

curl "https://files.pythonhosted.org/packages/fd/ae/98cb7a0cbb1d748ee547b058b14604bd0e9bf285a8e0cc5d148f8a8a952e/psycopg2-2.8.6.tar.gz" > psycopg2-2.8.6.tar.gz
export PATH=$PATH:/usr/pgsql-10/bin
pip install psycopg2-2.8.6.tar.gz
pip wheel psycopg2-2.7.7.tar.gz

sqlalchemy

curl 'https://files.pythonhosted.org/packages/c2/f6/11fcc1ce19a7cb81b1c9377f4e27ce3813265611922e355905e57c44d164/SQLAlchemy-1.1.15.tar.gz' > sql.tar.gz
pip install sql.tar.gz

sqlalchemy python

from sqlalchemy import create_engine
db_string = "postgres://zdb:new_password@localhost/zdb?host=/var/run/postgresql"
db = create_engine(db_string)
result_set = db.execute("SELECT * FROM playground")  
for r in result_set:  
    print(r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment