File tree Expand file tree Collapse file tree 2 files changed +66
-0
lines changed Expand file tree Collapse file tree 2 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 15
15
``` console
16
16
pip install sqlalchemy-fields
17
17
```
18
+
19
+ ## Extra SQLAlchemy column types
20
+
21
+ - Email
22
+ - File
23
+ - IP
24
+ - URL
25
+ - UUID
26
+
27
+ ``` python
28
+ from sqlalchemy import Column, Integer, create_engine
29
+ from sqlalchemy.orm import Session, declarative_base
30
+ from sqlalchemy_fields.types import IPAddress
31
+
32
+ Base = declarative_base()
33
+ engine = create_engine(" sqlite:///example.db" )
34
+
35
+ class Example (Base ):
36
+ __tablename__ = " example"
37
+
38
+ id = Column(Integer, primary_key = True )
39
+ ip = Column(IPAddress)
40
+
41
+
42
+ example = Example(ip = " 127.0.0.1" )
43
+ with Session(engine) as session:
44
+ session.add(example)
45
+ session.commit()
46
+ print (example.ip)
47
+ """
48
+ IPv4Address("127.0.0.1")
49
+ """
50
+ ```
Original file line number Diff line number Diff line change 15
15
``` console
16
16
pip install sqlalchemy-fields
17
17
```
18
+
19
+ ## SQLAlchemy types
20
+
21
+ - Email
22
+ - File
23
+ - IP
24
+ - URL
25
+ - UUID
26
+
27
+ ``` python
28
+ from sqlalchemy import Column, Integer, create_engine
29
+ from sqlalchemy.orm import Session, declarative_base
30
+ from sqlalchemy_fields.types import IPAddress
31
+
32
+ Base = declarative_base()
33
+ engine = create_engine(" sqlite:///example.db" )
34
+
35
+ class Example (Base ):
36
+ __tablename__ = " example"
37
+
38
+ id = Column(Integer, primary_key = True )
39
+ ip = Column(IPAddress)
40
+
41
+
42
+ example = Example(ip = " 127.0.0.1" )
43
+ with Session(engine) as session:
44
+ session.add(example)
45
+ session.commit()
46
+ print (example.ip)
47
+ """
48
+ IPv4Address("127.0.0.1")
49
+ """
50
+ ```
You can’t perform that action at this time.
0 commit comments