https://github.com/coryleach/unitysqlite
SQLite Package for Unity
https://github.com/coryleach/unitysqlite
openupm package package-manager sql sqlite sqlite3 unity unity3d upm
Last synced: about 1 month ago
JSON representation
SQLite Package for Unity
- Host: GitHub
- URL: https://github.com/coryleach/unitysqlite
- Owner: coryleach
- License: mit
- Created: 2019-11-21T19:43:57.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-13T22:48:36.000Z (almost 5 years ago)
- Last Synced: 2025-02-28T16:55:40.324Z (2 months ago)
- Topics: openupm, package, package-manager, sql, sqlite, sqlite3, unity, unity3d, upm
- Language: C#
- Homepage:
- Size: 2.6 MB
- Stars: 27
- Watchers: 3
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
![]()
Gameframe.SQLite 👋
[](https://www.codacy.com/manual/coryleach/UnitySQLite?utm_source=github.com&utm_medium=referral&utm_content=coryleach/UnitySQLite&utm_campaign=Badge_Grade)

[](https://openupm.com/packages/com.gameframe.sceneswitcher/)
[](https://twitter.com/coryleach)
SQLite Package
## Quick Package Install
#### Using UnityPackageManager (for Unity 2019.3 or later)
Open the package manager window (menu: Window > Package Manager)
Select "Add package from git URL...", fill in the pop-up with the following link:
https://github.com/coryleach/UnitySQLite.git#1.0.2#### Using UnityPackageManager (for Unity 2019.1 or later)
Find the manifest.json file in the Packages folder of your project and edit it to look like this:
```js
{
"dependencies": {
"com.gameframe.sqlite": "https://github.com/coryleach/UnitySQLite.git#1.0.2",
...
},
}
```## Usage
```c#
using Mono.Data.SqliteClient;// Create database
string path = Application.persistentDataPath + "/" + "My_Test_Database";
string connection = "URI=file:" + path;// Open connection
IDbConnection dbcon = new SqliteConnection(connection);
dbcon.Open();// Create table
IDbCommand dbcmd;
dbcmd = dbcon.CreateCommand();
string q_createTable = "CREATE TABLE IF NOT EXISTS my_table (id INTEGER PRIMARY KEY, val INTEGER )";dbcmd.CommandText = q_createTable;
dbcmd.ExecuteReader();// Insert values in table
IDbCommand cmnd = dbcon.CreateCommand();
cmnd.CommandText = "INSERT INTO my_table (id, val) VALUES (0, 5)";
cmnd.ExecuteNonQuery();// Read and print all values in table
IDbCommand cmnd_read = dbcon.CreateCommand();
IDataReader reader;
string query ="SELECT * FROM my_table";
cmnd_read.CommandText = query;
reader = cmnd_read.ExecuteReader();while (reader.Read())
{
Debug.Log("id: " + reader[0].ToString());
Debug.Log("val: " + reader[1].ToString());
}// Close connection
dbcon.Close();
```## Author
👤 **Cory Leach**
* Twitter: [@coryleach](https://twitter.com/coryleach)
* Github: [@coryleach](https://github.com/coryleach)## Show your support
Give a ⭐️ if this project helped you!
***
_This README was generated with ❤️ by [Gameframe.Packages](https://github.com/coryleach/unitypackages)_