import TabItem from "@theme/TabItem"; import Tabs from "@theme/Tabs";
CREATE A DATABASE
Because Glitter data is kept in tables in a database, if you wish to use it for data storage and retrieval, you must first establish your own database and data tables. To construct a database, use the CREATE DATABASE
statement.
Using the SDK
We currently offer SDKs in Python and JavaScript, and both versions of the SDKs have ways of constructing databases. Here's an example of how to make a database.
<Tabs defaultValue="Python" values={[ { label: "Python", value: "Python" }, { label: "JavaScript", value: "JavaScript" }, { label: "Golang", value: "Golang" }, ]}
The Python SDK's create_database()
method can be used to create a database.
XIAN_HOST = "https://api.xian.glitter.link"
#LOCAL_HOST = "http://127.0.0.1:41317"
CHAIN_ID = "glitter_12000-1"
mk = MnemonicKey("your mnemonic words")
client = LCDClient(
chain_id=CHAIN_ID,
url=XIAN_HOST,
gas_prices=Coins.from_str("0.15agli"),
gas_adjustment=Numeric.parse(1.5))
db = client.db(mk)
db.create_database("your_database_name")
You can create a database using the createDatabase()
method of the JavaScript SDK
const XIAN_HOST = "https://api.xian.glitter.link"
//const LOCAL_HOST = "http://127.0.0.1:41317"
const CHAIN_ID = "glitter_12000-1"
const mk = new MnemonicKey({"your mnemonic words"});
const client = new LCDClient({
URL: XIAN_HOST,
chainID: CHAIN_ID,
gasPrices: Coins.fromString('0.15agli'),
gasAdjustment: Numeric.parse(1.5),
});
const db = client.db(mk);
await db.createDatabase("your_database_name");
The Golang SDK's CreateDatabase()
method can be used to create a database.
resp, err := glitterClient.CreateDatabase(ctx, "your_database_name")