Home > Backend Development > Python Tutorial > What database to use for python data analysis?

What database to use for python data analysis?

(*-*)浩
Release: 2019-07-09 10:13:07
Original
3683 people have browsed it

SQLite is a very popular relational database that is widely used by a large number of applications because it is very lightweight. sqlite3 is a module that comes with the python standard distribution and can be used to process sqlite databases. The database can be saved to a file or in memory, here it is saved to memory.

What database to use for python data analysis?

Code: (Recommended learning: Python video tutorial)

import sqlite3
with sqlite3.connect(":memory:") as con:
    c=con.cursor()  #创建游标
    c.execute('''CREATE TABLE sensors(data text,city text,code text,sensor_id real,temperature real)''') #新建表,text和real分别表示字符串和数值的类型
    for table in c.execute("SELECT name FROM sqlite_master WHERE type='table'"):
        print "Table",table[0]
        c.execute("INSERT INTO sensors VALUES ('2016-11-05','Utrecht','Red',42,15.14)")
        c.execute("SELECT * FROM sensors")
        print c.fetchone()  #输出插入记录
        con.execute("DROP TABLE sensors")  #删除表
        print "# of tables",c.execute("SELECT COUNT(*) FROM sqlite_master WHERE type='table'").fetchone()[0]
c.close()
Copy after login

Running results:

Table sensors
(u'2016-11-05', u'Utrecht', u'Red', 42.0, 15.14)
# of tables 0
Copy after login

Relational database management system

Embedded database, suitable for embedded devices

SQLite is not a C/S database engine

Integrated into the user program

Implements most SQL standards

For more Python related technical articles, please visit the Python Tutorial column to learn!

The above is the detailed content of What database to use for python data analysis?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template