diff --git a/jedi/mixin/_sqlite3.pym b/jedi/mixin/_sqlite3.pym new file mode 100644 index 00000000..2151e652 --- /dev/null +++ b/jedi/mixin/_sqlite3.pym @@ -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 [''] diff --git a/test/completion/std.py b/test/completion/std.py index 9d105b42..6ea57f30 100644 --- a/test/completion/std.py +++ b/test/completion/std.py @@ -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 # -----------------