1. [atyu30@ns138 mediawiki]$ python
  2. Python 2.4.3 (#1, Jun 11 2009, 14:09:37)
  3. [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>> import cx_Oracle
  6. >>> db = cx_Oracle.connect('atyu30','atyu30','10.0.20.47:1521/YUYIZHI')
  7. Traceback (most recent call last):
  8.   File "", line 1, in ?
  9. TypeError: argument 1 must be unicode, not str
  10. >>> db1 = cx_Oracle.connect('atyu30/[email protected]:1521/YUYIZHI')
  11. Traceback (most recent call last):
  12.   File "", line 1, in ?
  13. TypeError: argument 1 must be unicode, not str
同样的方式在windows下操作就没问题
  1. Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit (Intel)] on win32
  2. Type "copyright", "credits" or "license()" for more information.
  3. >>> import cx_Oracle
  4. >>> conn = cx_Oracle.connect('atyu30','atyu30','10.0.20.47:1521/YUYIZHI')
  5. >>>

  6. >>> cursor = conn.cursor()
  7. >>> cursor.execute("""create table python_oracle(id number,name varchar2(50),password varchar(50),primary key(id))""")
  8. >>> cursor.execute("""insert into python_oracle values(1,'admin','password')""")
正确方法:
  1. [oracle@storage ~]$ python
  2. Python 2.4.3 (#1, Jun 11 2009, 14:09:37)
  3. [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>> import cx_Oracle
  6. >>> db = cx_Oracle.connect("atyu30/atyu30@//10.0.20.47/YUYIZHI")
  7. >>>
09-02 08:07