Implementasikan onCreate () untuk membuat SQLiteDatabase bersama tabel untuk data anda. Jadikan SQLiteOpenHelper sebagai subkelas Gunakan konstanta untuk nama tabel dan query pembuatan database. The dataframe (df) will contain the actual data. Untuk mengimplementasikan SQLite, anda perlu melakukan ini : Buat model data. The line that converts SQLite data to a Panda data frame is: We connect to the SQLite database using the line: Query = "SELECT country FROM Population WHERE population > 50000000 " SQLite dataset created from scriptĪn SQL query result can directly be stored in a panda dataframe: provides classes and functions to interact with a SQLite database. It creates the SQLite database containing one table with dummy data. If you are writing an app that needs to persist and query large amounts of data on. We create a simple dataset using this code:Ĭur.execute( "CREATE TABLE Population(id INTEGER PRIMARY KEY, country TEXT, population INT)")Ĭur.execute( "INSERT INTO Population VALUES(NULL,'Germany',81197537)")Ĭur.execute( "INSERT INTO Population VALUES(NULL,'France', 66415161)")Ĭur.execute( "INSERT INTO Population VALUES(NULL,'Spain', 46439864)")Ĭur.execute( "INSERT INTO Population VALUES(NULL,'Italy', 60795612)") We’ll also briefly cover the creation of the sqlite database table using Python. In this article we’ll demonstrate loading data from an SQLite database table into a Python Pandas Data Frame. An SQLite database can be read directly into Python Pandas (a data analysis library).
0 Comments
Leave a Reply. |