In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Install related packages
yum install python-devel mysql-devel zlib-devel openssl-devel
2. Install setup, mysql-python package
wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
wget http://downloads.sourceforge.net/project/mysql-python/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz
Decompression, each performed separately
python setup.py build
python setup.py install
3. Try to connect
#!/ usr/bin/evn python
#-*- coding: utf-8 -*-
import os, sys
import MySQLdb
#try:
db=MySQLdb.connect(host = 'localhost', user='root', passwd='oracle', db='mysql', unix_socket='/usr/local/mysql/mysql.sock')
#except MySQLdb.ERROR,e:
# print "Error %d:%s"%(e.args[0],e.args[1])
# exit(1)
cursor=db.cursor()
cursor.execute('select * from user')
result_set=cursor.fetchall()
print result_set
cursor.close()
db.close()
If it works, it's a success.
4. Insert MYISAM engine
#!/ usr/bin/evn python
#-*- coding: utf-8 -*-
import os, sys
import MySQLdb
#try:
db=MySQLdb.connect(host = 'localhost', user='root', passwd='oracle', db='mysql', unix_socket='/usr/local/mysql/mysql.sock')
#except MySQLdb.ERROR,e:
# print "Error %d:%s"%(e.args[0],e.args[1])
# exit(1)
cursor=db.cursor()
cursor.execute('use fastbase;')
for x in range(60000):
cursor.execute("insert into header(CIP, CMAC, CBIOS, UUID, SEQ, SALT, ALG, CHK) values('%s','AABBCCDDEEFF','',%s,%s,123456,'SHA','ABCDEFGHIJKLMNOPQRSTUVWXYZ123456');"%(x,x,x))
result_set=cursor.fetchall()
print result_set
cursor.close()
db.close()
INSERT HEADER table, MYISAM, 60000 data, 10.68s, size 4.6MB
INSERT HEADER table, MYISAM, 3000000 data, 9m44s, size 240MB
INSERT CONTENT table, ARCHIVE, 1500000 data, 39m14s, size 74MB
SELECT HEADER table, MYISAM, 3000000 data, 27.50s, size 240MB
SELECT CONTENT table, ARCHIVE, 1500000 data,>25m, size 74MB
SELECT CONTENT table, MYISAM, 1500000 data,>5m52s, size 1.7GB
SELECT CONTENT table, MYISAM, 2500000 data, 16.00s, size 273MB
SELECT CONTENT table, MYISAM, 2500000 data, 17.73s, size 13MB
SELECT CONTENT ON CONTENT, ARCHIVE, 2500000 DATA, TOP 100, 3m45s.
SELECT CONTENT ON CONTENT, ARCHIVE, 2500000 data,>12m52s.
SELECT CONTENT ON CONTENT, MYISAM, with index, 2500000 data, 1m00s.
FASTJOIN technology, ARCHIVE engine, 100 on both sides, 2.9s.
FASTJOIN technology, ARCHIVE engine, 10000 on both sides, 26s.
Using FASTJOIN technology, ARCHIVE engine, 100000 on both sides, 2m13.18s.
Use FASTJOIN technology, MYISAM engine, with index, 100000 on both sides, 27.01s.
Use FASTJOIN technology, MYISAM engine, with index, 2500000 on both sides, 7m30s.
5. Insert the ARCHIVE engine
ibid.
60000 data, 9.31s, size 350KB
6. Split strings and write files
#!/ usr/bin/evn python
#-*- coding: utf-8 -*-
import os, sys
str='abcd efg hi j 123'
output=str.split()
print output
print(output[1:])
print(output[:1])
print(output[1])
file=open('/tmp/wr.txt','a')
file.write(output[1])
file.write('\n')
file.close()
7. Operation Oracle
First install cx_Oracle
Go to http://cx-oracle.sourceforge.net/Download
Then install the python version using rpm.
After installation, you need to confirm that oracle client is installed
ImportError: libclntsh.so.11.1: cannot open shared object file: No such file or directory
In addition, the version should also pay attention to whether it is 64-bit or 32-bit
Also, join
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib/oracle/11.2/client/lib
Python is not recognized.
ORACLE_HOME also needs to be specified to execute
sqlplus user/passwd@10.0.0.5/hbdb or sqlplus user/passwd@MYDB
sqlplus: error while loading shared libraries: /usr/local/oracle/libnnz11.so: cannot restore segment prot after reloc: Permission denied
The easiest solution is to set SElinux to PERMISSIVE:
[root@localhost ~]# getenforce
Enforcing
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.