如何将excel文件行插入sqlite数据库 [英] How to insert excel file rows into sqlite database

查看:141
本文介绍了如何将excel文件行插入sqlite数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为db的sqlite数据库,其中包含名为student的表,列:名称和电子邮件。类似地,我有excel文件studentdb.xlsx具有类似的列名称和数千行。我想读取excel文件并通过php脚本将数据导入sqlite数据库。怎么做?



我尝试了什么:



我经历了PHPExcel库,但那是用于PHP的,使用mysql

I have a sqlite database named: db with table named student, columns: name and email. Similarly I have excel file studentdb.xlsx having the similar column name with thousand of rows. I want to read the excel file and import the data into sqlite database through a php script. How to do that?

What I have tried:

I went through PHPExcel library but that was for PHP using mysql

推荐答案

好吧, PHPExcel 声称是纯PHP库阅读和编写电子表格文件因此它应该能够让您执行任务中最困难的部分,即从 Excel 导入数据。下一个任务,即将数据存储到 sqlite 数据库中,应该很简单,因为 PHP 提供了所需的一切(请参阅文档: PHP:SQLite3 - 手册 [ ^ ])。
Well, PHPExcel claims to be "A pure PHP library for reading and writing spreadsheet files" hence it should provide you the ability to perform the most difficult part of your task, that is importing data from Excel. The next task, i.e. storing data into the sqlite database, should be simple, since PHP provides all that you need (see the documentation: PHP: SQLite3 - Manual[^]).


Hello all问题解决了!我使用PHPExcel库将行从xlsx文件导入到sqlite数据库。我从这里获得了帮助:



用我的sqlite代码替换mysql代码。
Hello all Problem is solved! I used the PHPExcel Library to import the rows from xlsx file to sqlite database.I took help from here:

Just replaced the mysql code with my sqlite code.


这篇关于如何将excel文件行插入sqlite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆