![]() ![]() If this page can be found by others searching for answers, it may save many hours of frustration.Īfter creating a new row in a table that uses AUTOINCREMENT to create the PRIMARY KEY, one may wish to determine the value of the new row-id, for example if the value is need for a new row in a related table that will be inserted next. The following solution was difficult to discover with the available documentation ( was unavailable). Trac (issue tracker, wiki, Subversion web frontend).The documentation has a section on the differences between APSW and pysqlite. ![]() In contrast to other wrappers such as pysqlite it focuses on being a minimal layer over SQLite attempting just to translate the complete SQLite API into Python. licence zlib/libpng license (or any OSI approved license of your choice) platforms Windows, POSIX Python versions 2.3 onwards, 3.1 onwardsĪPSW is a Python wrapper for the SQLite embedded relational database engine. row converter factory to easily and efficiently switch to a nonstandard type for rows (e.Factories for connection and cursor objects.licence zlib/libpng License platforms Windows /XP, POSIX, MacOS X Python versions 2.1 or later (1.x branch)/2.3 or later (2.0 branch). If you want to use other types like DATE and TIME in pysqlite, you need to use its "pysqlite types mode", where things can get a little nastier.SQLite only supports the basic types NULL, INTEGER, FLOAT, TEXT and BLOB.It's very cool for small databased application, because you do not have to start an external DBMS.It doesn't put all data in memory like gadfly does (yet you can do that if you want, just use ':memory:' as filename.It's extensible in a very easy way via Python. ![]() The main engine is written in C, so it should be faster than the gadfly implementation in Python.I think SQLite may be a good replacement for gadfly, because: platforms Built and tested under Linux and Win2K. Rather than unique index for the unit tests to still work the column names don’t include the ‘_id’ part of what might actually be in the database.Licence Sources are uncopyrighted. Primary_key = CompositeKey('column1', 'column2') It doesn’t break my run of unit tests which is also a bonus.įinally, a compound primary is better specified in the model as, class Meta: It also seems that foreign keys are not honored by default and that they have to be explicity requested with, database = SqliteDatabase(app.config, pragmas=((‘foreign_keys’, ‘on’),)) This comes, however, from a Playhouse extension which I want to avoid. ![]() (though like most ORMs it doesn’t think you need the id column I prefer to see it). Rather than id = IntegerField(primary_key=True) I had cursed PeeWee for not appearing to support incrementing primary keys when inserting new records and having to include a line to calculate the next insert id via a query (not a safe operation, I know), but it turns out that there is an alternate way to specify a primary key in the PeeWee model: id = PrimryKeyField() Just a wee nugget I picked up from the PeeWee documentation that needs to be saved for later reference ‘cos I’m bound to forget this with later projects and I’m including unnecessary code in my applications. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |