mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-11 08:11:50 +08:00
improve sqlite3 support -> added mixins -> fixes #84
This commit is contained in:
26
jedi/mixin/_sqlite3.pym
Normal file
26
jedi/mixin/_sqlite3.pym
Normal file
@@ -0,0 +1,26 @@
|
||||
def connect(database, timeout=None, isolation_level=None, detect_types=None, factory=None):
|
||||
return Connection()
|
||||
|
||||
|
||||
class Connection():
|
||||
def cursor(self):
|
||||
return Cursor()
|
||||
|
||||
|
||||
class Cursor():
|
||||
def cursor(self):
|
||||
return Cursor()
|
||||
|
||||
def fetchone(self):
|
||||
return Row()
|
||||
|
||||
def fetchmany(self, size=cursor.arraysize):
|
||||
return [self.fetchone()]
|
||||
|
||||
def fetchall(self):
|
||||
return [self.fetchone()]
|
||||
|
||||
|
||||
class Row():
|
||||
def keys(self):
|
||||
return ['']
|
||||
@@ -67,6 +67,26 @@ def example(a):
|
||||
#? str()
|
||||
example('')
|
||||
|
||||
|
||||
# -----------------
|
||||
# sqlite3 (#84)
|
||||
# -----------------
|
||||
|
||||
import sqlite3
|
||||
#? sqlite3.Connection()
|
||||
con = sqlite3.connect()
|
||||
#? sqlite3.Cursor()
|
||||
c = con.cursor()
|
||||
#? sqlite3.Row()
|
||||
row = c.fetchall()[0]
|
||||
#? str()
|
||||
row.keys()[0]
|
||||
|
||||
def huhu(db):
|
||||
"""db (sqlite3.Connection): the db connection"""
|
||||
#? sqlite3.Connection()
|
||||
db
|
||||
|
||||
# -----------------
|
||||
# various regression tests
|
||||
# -----------------
|
||||
|
||||
Reference in New Issue
Block a user