Used to process simple DB in Windows by using Python, C++ and C# before, the DB was Microsoft Access and SQLite.
1, Python to import DB to Microsoft Access, code as below, for illustration only,
conn = win32com.client.Dispatch("ADODB.Connection")
DSN="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + db
conn.Open(DSN)
insertfmt = "SQL command here"
sql = insertfmt.format("prepare the data here")
conn.Execute(sql) //execute sql command2, C# to create and insert SQLite db, for illustration only,
SQLiteConnection.CreateFile(dbFileName);
conn = new SQLiteConnection("Data Source=" + dbFileName);
conn.Open();
cmd.CommandText ="put your sql command here";
cmd.ExecuteNonQuery(); //execute command3, C++SQLiteEncrypt, for illustration only,
CppSQLite3DB db;
db.open(gszFile); //gszFile is the db name and location
// supply password key after db file opened
db.key("123456789", (int)strlen("123456789"));
// reset / change your password phrase on the fly
db.rekey("987654321", (int)strlen("987654321"));
CppSQLite3Table t1 = db.getTable("SELECT * FROM APDU;");
//display the table content
for (fld = 0; fld < t1.numFields(); fld++)
{
cout << t1.fieldName(fld) << "|";
}

本文介绍了使用Python、C#及C++进行数据库操作的方法,包括导入数据到Microsoft Access、创建及插入SQLite数据库,以及对SQLite数据库进行加密处理。通过具体代码示例展示了不同场景下的数据库操作流程。
604

被折叠的 条评论
为什么被折叠?



