JDBC¶
Overview¶
Data can be sent from/to AMI using a JDBC connection. This connection is controlled by the configuration file (see the Configuration Guide for more details).
Example: Java¶
Example: Python¶
Prerequisites: A jre (Java runtime environment, for JDBC) needs to be installed.
-
Install the JayDeBeApi module.
JayDeBeApi is an adapter of JDBC for python. You can install it using pip:
Alternative ways to install JayDeBeApi: https://pypi.org/project/JayDeBeApi/
-
Start AMI One
-
Connect to amisql from python:
-
You'll need the path to the out.jar file. This can be found in the ami/amione/lib folder.
-
Find the server hostname and ami.db.jdbc.port (default is 3280).
-
Copy this script, replacing the <placeholders> with appropriate values:
-
-
To run queries, create a cursor:
-
Queries can then be executed using the execute method:
-
Results are fetched using the fetchall method, which returns a list:
-
Close the cursor once finished:
You can also execute queries within a with
block for the cursor so you don't have to worry about closing it:
Example: DBeaver¶
-
Add driver configuration in DBeaver
- Go to Database -> Driver Manager, Open driver manager dialogue and click New
- Configure the AMIDbJdbcDriver
Parameter Description Example Driver Name Name of your driver. It can be any name you like AmiDbJdbcDriver Driver Type Driver Provider Generic Class Name JDBC driver class name com.f1.ami.amidb.jdbc.AmiDbJdbcDriver URL Template Template of driver URL, should follow the format like: jdbc:amisql:<host>:<jdbc port><login details> jdbc:amisql:localhost:3280?username=demo&password=demo123 Default Port Default AMI JDBC port is 3280 3280 Default Database Default database is AMI AMI Default User Default user name is demo demo Description Description of the driver driver for connection to AMIDB - Go to Libraries tab and add the out.jar file(/amione/lib/out.jar) into it and hit ok
-
Establish Database Connection With the AMIDbJdbc Driver
- Go to Database -> New Database Connection and select the AMIDbJdbc driver we just configured
- Enter the URL and your login information. Your AMI Database is ready to go.