File: inspect.py

package info (click to toggle)
sqlalchemy 1.4.46%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 22,444 kB
  • sloc: python: 341,434; ansic: 1,760; makefile: 226; xml: 17; sh: 7
file content (43 lines) | stat: -rw-r--r-- 856 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
test inspect()

however this is not really working

"""
from sqlalchemy import Column
from sqlalchemy import create_engine
from sqlalchemy import inspect
from sqlalchemy import Integer
from sqlalchemy import String
from sqlalchemy.engine.reflection import Inspector
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Mapper

Base = declarative_base()


class A(Base):
    __tablename__ = "a"

    id = Column(Integer, primary_key=True)
    data = Column(String)


a1 = A(data="d")

e = create_engine("sqlite://")

# TODO: I can't get these to work, pylance and mypy both don't want
# to accommodate for different types for the first argument

t: bool = inspect(a1).transient

m: Mapper = inspect(A)

inspect(e).get_table_names()

i: Inspector = inspect(e)


with e.connect() as conn:
    inspect(conn).get_table_names()