8000 Stubs (.pyi) for type definition for connection and cursor objects by maximmasiutin · Pull Request #67 · mysql/mysql-connector-python · GitHub
[go: up one dir, main page]

Skip to content

Stubs (.pyi) for type definition for connection and cursor objects #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added stubs/mysql/__init__.pyi
Empty file.
47 changes: 47 additions & 0 deletions stubs/mysql/connector/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from .abstracts import MySQLConnectionAbstract as MySQLConnectionAbstract
from .connection import MySQLConnection as MySQLConnection
from .connection_cext import CMySQLConnection as CMySQLConnection
from .constants import (
CharacterSet as CharacterSet,
ClientFlag as ClientFlag,
FieldFlag as FieldFlag,
FieldType as FieldType,
RefreshOption as RefreshOption,
)
from .dbapi import (
BINARY as BINARY,
Binary as Binary,
DATETIME as DATETIME,
Date as Date,
DateFromTicks as DateFromTicks,
NUMBER as NUMBER,
ROWID as ROWID,
STRING as STRING,
Time as Time,
TimeFromTicks as TimeFromTicks,
Timestamp as Timestamp,
TimestampFromTicks as TimestampFromTicks,
apilevel as apilevel,
paramstyle as paramstyle,
threadsafety as threadsafety,
)
from .errors import (
DataError as DataError,
DatabaseError as DatabaseError,
Error as Error,
IntegrityError as IntegrityError,
InterfaceError as InterfaceError,
InternalError as InternalError,
NotSupportedError as NotSupportedError,
OperationalError as OperationalError,
ProgrammingError as ProgrammingError,
Warning as Warning,
custom_error_exception as custom_error_exception,
)
from typing import Any

HAVE_CEXT: bool

def connect(*args: Any, **kwargs: Any) -> MySQLConnectionAbstract: ...

Connect = connect
192 changes: 192 additions & 0 deletions stubs/mysql/connector/abstracts.pyi
8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
import abc
from . import errors as errors
from .catch23 import BYTE_TYPES as BYTE_TYPES, make_abc as make_abc
from .constants import (
CharacterSet as CharacterSet,
ClientFlag as ClientFlag,
DEFAULT_CONFIGURATION as DEFAULT_CONFIGURATION,
)
from .conversion import MySQLConverterBase as MySQLConverterBase
from .optionfiles import MySQLOptionsParser as MySQLOptionsParser
from abc import abstractmethod
from typing import Any, Optional

class MySQLConnectionAbstract(metaclass=abc.ABCMeta):
converter: Any = ...
def __init__(self, **kwargs: Any) -> None: ...
@property
def user(self): ...
@property
def server_host(self): ...
@property
def server_port(self): ...
@property
def unix_socket(self): ...
@property
@abc.abstractmethod
def database(self) -> MySQLConnectionAbstract: ...
@database.setter
def database(self, value: Any) -> MySQLConnectionAbstract: ...
@property
def can_consume_results(self): ...
def config(self, **kwargs: Any) -> None: ...
def get_server_version(self): ...
def get_server_info(self): ...
@property
@abc.abstractmethod
def in_transaction(self) -> Any: ...
def set_client_flags(self, flags: Any): ...
def isset_client_flag(self, flag: Any): ...
@property
def time_zone(self): ...
@time_zone.setter
def time_zone(self, value: Any) -> None: ...
@property
def sql_mode(self): ...
@sql_mode.setter
def sql_mode(self, value: Any) -> None: ...
@abstractmethod
def info_query(self, query: Any) -> MySQLCursorAbstract: ...
def set_login(
self, username: Optional[Any] = ..., password: Optional[Any] = ...
) -> None: ...
def set_unicode(self, value: bool = ...) -> None: ...
@property
def autocommit(self): ...
@autocommit.setter
def autocommit(self, value: Any) -> None: ...
@property
def get_warnings(self): ...
@get_warnings.setter
def get_warnings(self, value: Any) -> None: ...
@property
def raise_on_warnings(self): ...
@raise_on_warnings.setter
def raise_on_warnings(self, value: Any) -> None: ...
@property
def unread_result(self) -> bool: ...
@unread_result.setter
def unread_result(self, value: bool): ...
@property
def charset(self): ...
@property
def python_charset(self): ...
def set_charset_collation(
self, charset: Optional[Any] = ..., collation: Optional[Any] = ...
) -> None: ...
@property
def collation(self): ...
@abstractmethod
def disconnect(self) -> Any: ...
close: Any = ...
def connect(self, **kwargs: Any) -> MySQLConnectionAbstract: ...
def reconnect(self, attempts: int = ..., delay: int = ...) -> None: ...
@abstractmethod
def is_connected(self) -> Any: ...
@abstractmethod
def ping(
self, reconnect: bool = ..., attempts: int = ..., delay: int = ...
) -> Any: ...
@abstractmethod
def commit(self) -> Any: ...
@abstractmethod
def cursor(
self,
buffered: Optional[Any] = ...,
raw: Optional[Any] = ...,
prepared: Optional[Any] = ...,
cursor_class: Optional[Any] = ...,
dictionary: Optional[Any] = ...,
named_tuple: Optional[Any] = ...,
) -> MySQLCursorAbstract: ...
@abstractmethod
def rollback(self) -> Any: ...
def start_transaction(
self,
consistent_snapshot: bool = ...,
isolation_level: Optional[Any] = ...,
readonly: Optional[Any] = ...,
) -> None: ...
def reset_session(
self,
user_variables: Optional[Any] = ...,
session_variables: Optional[Any] = ...,
) -> None: ...
def set_converter_class(self, convclass: Any) -> None: ...
@abstractmethod
def get_rows(
self,
count: Optional[Any] = ...,
binary: bool = ...,
columns: Optional[Any] = ...,
) -> Any: ...
def cmd_init_db(self, database: Any) -> None: ...
def cmd_query(
self,
query: Any,
raw: bool = ...,
buffered: bool = ...,
raw_as_string: bool = ...,
) -> None: ...
def cmd_query_iter(self, statements: Any) -> None: ...
def cmd_refresh(self, options: Any) -> None: ...
def cmd_quit(self) -> None: ...
def cmd_shutdown(self, shutdown_type: Optional[Any] = ...) -> None: ...
def cmd_statistics(self) -> None: ...
def cmd_process_info(self) -> None: ...
def cmd_process_kill(self, mysql_pid: Any) -> None: ...
def cmd_debug(self) -> None: ...
def cmd_ping(self) -> None: ...
def cmd_change_user(
self,
username: str = ...,
password: str = ...,
database: str = ...,
charset: int = ...,
) -> None: ...
def cmd_stmt_prepare(self, statement: Any) -> None: ...
def cmd_stmt_execute(
self,
statement_id: Any,
data: Any = ...,
parameters: Any = ...,
flags: int = ...,
) -> None: ...
def cmd_stmt_close(self, statement_id: Any) -> None: ...
def cmd_stmt_send_long_data(
self, statement_id: Any, param_id: Any, data: Any
) -> None: ...
def cmd_stmt_reset(self, statement_id: Any) -> None: ...
def cmd_reset_connection(self) -> None: ...

class MySQLCursorAbstract(metaclass=abc.ABCMeta):
arraysize: int = ...
def __init__(self) -> None: ...
@abstractmethod
def callproc(self, procname: Any, args: Any = ...) -> Any: ...
@abstractmethod
def close(self) -> Any: ...
@abstractmethod
def execute(self, operation: Any, params: Any = ..., multi: bool = ...) -> Any: ...
@abstractmethod
def executemany(self, operation: Any, seqparams: Any) -> Any: ...
@abstractmethod
def fetchone(self) -> Any: ...
@abstractmethod
def fetchmany(self, size: int = ...) -> Any: ...
@abstractmethod
def fetchall(self) -> Any: ...
def nextset(self) -> None: ...
def setinputsizes(self, sizes: Any) -> None: ...
def setoutputsize(self, size: Any, column: Optional[Any] = ...) -> None: ...
def reset(self, free: bool = ...) -> None: ...
@property
@abc.abstractmethod
def description(self) -> Any: ...
@property
@abc.abstractmethod
def rowcount(self) -> Any: ...
@property
@abc.abstractmethod
def lastrowid(self) -> Any: ...
def fetchwarnings(self): ...
116 changes: 116 additions & 0 deletions stubs/mysql/connector/connection.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
from . import errors as errors
from .abstracts import (
MySQLConnectionAbstract as MySQLConnectionAbstract,
MySQLCursorAbstract as MySQLCursorAbstract,
)
from .authentication import get_auth_plugin as get_auth_plugin
from .catch23 import PY2 as PY2, isstr as isstr
from .constants import (
ClientFlag as ClientFlag,
NET_BUFFER_LENGTH as NET_BUFFER_LENGTH,
ServerCmd as ServerCmd,
ServerFlag as ServerFlag,
ShutdownType as ShutdownType,
flag_is_set as flag_is_set,
)
from .conversion import MySQLConverter as MySQLConverter
from .cursor import (
CursorBase as CursorBase,
MySQLCursor as MySQLCursor,
MySQLCursorBuffered as MySQLCursorBuffered,
MySQLCursorBufferedDict as MySQLCursorBufferedDict,
MySQLCursorBufferedNamedTuple as MySQLCursorBufferedNamedTuple,
MySQLCursorBufferedRaw as MySQLCursorBufferedRaw,
MySQLCursorDict as MySQLCursorDict,
MySQLCursorNamedTuple as MySQLCursorNamedTuple,
MySQLCursorPrepared as MySQLCursorPrepared,
MySQLCursorRaw as MySQLCursorRaw,
)
from .network import (
MySQLTCPSocket as MySQLTCPSocket,
MySQLUnixSocket as MySQLUnixSocket,
)
from .protocol import MySQLProtocol as MySQLProtocol
from .utils import int4store as int4store
from typing import Any, Optional

class MySQLConnection(MySQLConnectionAbstract):
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def shutdown(self) -> None: ...
def close(self) -> None: ...
disconnect: Any = ...
@property
def in_transaction(self): ...
def get_row(self, binary: bool = ..., columns: Optional[Any] = ...): ...
@property
def get_rows(
self,
count: Optional[Any] = ...,
binary: Optional[bool] = ...,
columns: Optional[Any] = ...,
): ...
def consume_results(self) -> None: ...
def cmd_init_db(self, database: Any): ...
def cmd_query(
self,
query: Any,
raw: bool = ...,
buffered: bool = ...,
raw_as_string: bool = ...,
): ...
def cmd_query_iter(self, statements: Any) -> None: ...
def cmd_refresh(self, options: Any): ...
def cmd_quit(self): ...
def cmd_shutdown(self, shutdown_type: Optional[Any] = ...): ...
def cmd_statistics(self): ...
def cmd_process_kill(self, mysql_pid: Any): ...
def cmd_debug(self): ...
def cmd_ping(self): ...
def cmd_change_user(
self,
username: str = ...,
password: str = ...,
database: str = ...,
charset: int = ...,
): ...
@property
def database(self) -> MySQLConnection: ...
@database.setter
def database(self, value: Any) -> MySQLConnection: ...
def is_connected(self): ...
def reset_session(
self,
user_variables: Optional[Any] = ...,
session_variables: Optional[Any] = ...,
) -> None: ...
def reconnect(self, attempts: int = ..., delay: int = ...) -> None: ...
def ping(
self, reconnect: bool = ..., attempts: int = ..., delay: int = ...
) -> None: ...
@property
def connection_id(self): ...
def cursor(
self,
buffered: Optional[Any] = ...,
raw: Optional[Any] = ...,
prepared: Optional[Any] = ...,
cursor_class: Optional[Any] = ...,
dictionary: Optional[Any] = ...,
named_tuple: Optional[Any] = ...,
) -> MySQLCursorAbstract: ...
def commit(self) -> None: ...
def rollback(self) -> None: ...
def info_query(self, query: Any): ...
def cmd_stmt_prepare(self, statement: Any): ...
def cmd_stmt_execute(
self,
statement_id: Any,
data: Any = ...,
parameters: Any = ...,
flags: int = ...,
): ...
def cmd_stmt_close(self, statement_id: Any) -> None: ...
def cmd_stmt_send_long_data(self, statement_id: Any, param_id: Any, data: Any): ...
def cmd_stmt_reset(self, statement_id: Any) -> None: ...
def cmd_reset_connection(self) -> None: ...
def handle_unread_result(self) -> None: ...
Loading
0