Skip to content

Commit 91df71d

Browse files
committed
Updated example
1 parent 1d44221 commit 91df71d

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

examples/using_database_mind_text2sql.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from uuid import uuid4
22

33
from openai import OpenAI
4-
from mindsdb_sdk.utils.mind import create_mind
4+
from mindsdb_sdk.utils.mind import create_mind, DatabaseConfig
55
import os
66

77

@@ -21,22 +21,28 @@
2121
base_url=base_url
2222
)
2323

24-
# create a database mind
25-
mind = create_mind(
26-
name = f'my_house_data_mind_{uuid4().hex}',
27-
description= 'House Sales',
28-
base_url= base_url,
29-
api_key= MINDSDB_API_KEY,
30-
model= model_name,
31-
data_source_type='postgres',
32-
data_source_connection_args={
24+
# Create a Database Config.
25+
pg_config = DatabaseConfig(
26+
description='House Sales',
27+
type='postgres',
28+
connection_args={
3329
'user': 'demo_user',
3430
'password': 'demo_password',
3531
'host': 'samples.mindsdb.com',
3632
'port': '5432',
3733
'database': 'demo',
3834
'schema': 'demo_data'
39-
}
35+
},
36+
tables=['house_sales']
37+
)
38+
39+
# create a database mind
40+
mind = create_mind(
41+
base_url= base_url,
42+
api_key= MINDSDB_API_KEY,
43+
name = f'my_house_data_mind_{uuid4().hex}',
44+
data_source_configs=[pg_config],
45+
model= model_name
4046
)
4147

4248
# Actually pass in our tool to get a SQL completion.

0 commit comments

Comments
 (0)