In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "python how to read a directory under all the sqlite files", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "python how to read all the sqlite files under a directory"!
Import sqlite3 as db
Import os
If name== "main":
If os.path.exists (". / output/test.db"): os.remove (". / output/test.db") conn_write = db.connect ('. / output/test.db') cursor_write = conn_write.cursor () cursor_write.execute ("CREATE TABLE nav_test (test_id varchar) default'', value smallint default 0) ") rootdir ='. / test/' list = os.listdir (rootdir) / / Loop open all sqlite files under the test directory for i in range (0Len (list)): path = os.path.join (rootdir) List [I]) conn_read = db.connect (path) cursor_read = conn_read.cursor () rows = cursor_read.execute (".") / / read data line by line for line in rows: str1 = line [0] str2 = line [1]. . . Cursor_write.execute ("INSERT INTO nav_test VALUES ('{0}','{1}') Format (str1,str2) Thank you for your reading, the above is the content of "how python reads all sqlite files under a directory". After the study of this article, I believe you have a deeper understanding of how python reads all sqlite files under a directory, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.