using System.Collections; using System.Collections.Generic; using UnityEngine; using Mono.Data.Sqlite; // 注意:这取决于你使用的SQLite库 public class SQLiteExample : MonoBehaviour { // 数据库文件路径 private string dbPath = "URI=file:" + Application.dataPath + "/MyDatabase.db"; void Start() { // 示例:连接数据库并创建表 SqliteConnection conn = new SqliteConnection(dbPath); conn.Open(); string createTable = "CREATE TABLE IF NOT EXISTS Players (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "score INTEGER)"; SqliteCommand cmd = conn.CreateCommand(); cmd.CommandText = createTable; cmd.ExecuteNonQuery(); conn.Close(); Debug.Log("数据库表已创建或已存在。"); } // 其他数据库操作... }
#############################
标签:unity3d,sqlite,数据库,cmd,System,using,conn From: https://www.cnblogs.com/herd/p/18297430