- [atyu30@ns138 mediawiki]$ python
- Python 2.4.3 (#1, Jun 11 2009, 14:09:37)
- [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
- Type "help", "copyright", "credits" or "license" for more information.
- >>> import cx_Oracle
- >>> db = cx_Oracle.connect('atyu30','atyu30','10.0.20.47:1521/YUYIZHI')
- Traceback (most recent call last):
- File "", line 1, in ?
- TypeError: argument 1 must be unicode, not str
- >>> db1 = cx_Oracle.connect('atyu30/[email protected]:1521/YUYIZHI')
- Traceback (most recent call last):
- File "", line 1, in ?
- TypeError: argument 1 must be unicode, not str
同样的方式在windows下操作就没问题
- Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit (Intel)] on win32
- Type "copyright", "credits" or "license()" for more information.
- >>> import cx_Oracle
- >>> conn = cx_Oracle.connect('atyu30','atyu30','10.0.20.47:1521/YUYIZHI')
- >>>
- >>> cursor = conn.cursor()
- >>> cursor.execute("""create table python_oracle(id number,name varchar2(50),password varchar(50),primary key(id))""")
- >>> cursor.execute("""insert into python_oracle values(1,'admin','password')""")
正确方法:
- [oracle@storage ~]$ python
- Python 2.4.3 (#1, Jun 11 2009, 14:09:37)
- [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
- Type "help", "copyright", "credits" or "license" for more information.
- >>> import cx_Oracle
- >>> db = cx_Oracle.connect("atyu30/atyu30@//10.0.20.47/YUYIZHI")
- >>>
09-02 08:07