Update app.py
Browse files
app.py
CHANGED
@@ -1,41 +1,16 @@
|
|
1 |
-
import os
|
2 |
-
|
3 |
from pyairtable import Table
|
4 |
-
from pyairtable.formulas import match
|
5 |
-
from dotenv import load_dotenv, find_dotenv
|
6 |
-
load_dotenv(find_dotenv())
|
7 |
-
|
8 |
-
AIRTABLE_TOKEN = os.getenv('patmeLtGxrVz8HN1C.699482b9f0c5ea37997a38ff8964f71726630d4859f3eef542aaff9f097bba86')
|
9 |
-
BASE_ID = os.getenv('app4WdpCpbne8JVJU')
|
10 |
-
table_name='users'
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
|
17 |
-
|
18 |
-
formula = match(filter)
|
19 |
-
table = Table(AIRTABLE_TOKEN, BASE_ID, table_name)
|
20 |
-
result = table.all(formula=formula)
|
21 |
-
return result
|
22 |
|
23 |
-
|
24 |
-
formula = match(filter)
|
25 |
-
table = Table(AIRTABLE_TOKEN, BASE_ID, table_name)
|
26 |
-
record = table.all(formula=formula)
|
27 |
-
if len(record) > 0:
|
28 |
-
id = record[0]['id']
|
29 |
-
result = table.update(id, update)
|
30 |
-
return result
|
31 |
-
else:
|
32 |
-
return []
|
33 |
-
|
34 |
-
result = create_record('users', {'username': 'ansentase'})
|
35 |
-
print(result)
|
36 |
|
37 |
-
|
38 |
-
|
|
|
39 |
|
40 |
-
|
41 |
-
# print(result)
|
|
|
|
|
|
|
1 |
from pyairtable import Table
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
# Set up the connection to our Airtable table
|
4 |
+
BASE_ID = "app4WdpCpbne8JVJU"
|
5 |
+
API_KEY="patmeLtGxrVz8HN1C.699482b9f0c5ea37997a38ff8964f71726630d4859f3eef542aaff9f097bba86"
|
6 |
+
TABLE_NAME="pytable"
|
7 |
|
8 |
+
table = Table(API_KEY, BASE_ID, TABLE_NAME)
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
same="ansentase"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
add_this={
|
13 |
+
"Name":same
|
14 |
+
}
|
15 |
|
16 |
+
table.create(add_this)
|
|