Esempio n. 1
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import mosql.psycopg2_escape
from mosql.util import escape
s = "Hello, 'World'! and slash \me"

print escape(s)

import psycopg2
mosql.psycopg2_escape.conn = psycopg2.connect(dbname='mosky')

print escape(s)


import mosql.MySQLdb_escape
from mosql.util import escape
s = "Hello, 'World\xcc'! and slash \me"

print escape(s)

import MySQLdb
mosql.MySQLdb_escape.conn = MySQLdb.connect(user='******', db='mosky', charset='big5')

print escape(s)
Esempio n. 2
0
if cur.rowcount == 0:
    cur.execute("insert into person values ('dara', 'Dara Scully')")
    conn.commit()

cur.close()

# --- end of preparation ---

# --- main ---

cur = conn.cursor()

bytes = ''.join(unichr(i) for i in range(1, 128)).encode('utf-8')
bytes += ''.join(unichr(i) for i in range(28204, 28224)).encode('utf-8')

cur.execute("update person set name='%s' where person_id='dara'" % escape(bytes))
conn.commit()

cur.execute("select name from person where person_id='dara'")

for row in cur:
    name = row[0].decode('utf-8')

    print 'Check the Incontinuity:'
    count = 0
    for i in range(1, len(name)):
        diff = ord(name[i]) - ord(name[i-1])
        if 1 < diff < 20000:
            print '%s (%s) - %s (%s)' % (name[i], ord(name[i]), name[i-1], ord(name[i-1]))
            count += 1
    print 'count:', count,
Esempio n. 3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import mosql.psycopg2_escape
from mosql.util import escape

s = "Hello, 'World'! and slash \me"

print escape(s)

import psycopg2

mosql.psycopg2_escape.conn = psycopg2.connect(dbname="mosky")

print escape(s)


import mosql.MySQLdb_escape
from mosql.util import escape

s = "Hello, 'World\xcc'! and slash \me"

print escape(s)

import MySQLdb

mosql.MySQLdb_escape.conn = MySQLdb.connect(user="******", db="mosky", charset="big5")

print escape(s)