question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal for create/destroy database

See original GitHub issue

There is a common use case of creating/destroying databases, for example when running tests.

Currently there is no support for automating detecting the source database and acting appropriately, for example;

x = SqliteDatabase("file:/tmp/lala.sql", uri=True)
x.create_database() # this would create /tmp/lala.sql
x.destroy_database() # this would unlink /tmp/lala

x = SqliteDatabase(":memory:", uri=True)
x.create_database() # this would create in-memory db space
x.destroy_database() # this would close all connections, thus destroying DB space

x = MySQLDatabase(host='127.0.0.1', database='helloworld')
x.create_database() # this would execute "CREATE DATABASE helloworld;"
x.destroy_database() # this would execute "DROP DATABASE helloworld;"

I’ve got the majority of the above working for Sqlite, however I haven’t done Postgres or MySQL yet.

If this was put forward as a well formed PR, would this sort of functionality be accepted into the core, or playhouse?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
coleifercommented, Dec 29, 2015

I’ve always felt that this type of thing did not belong as a part of peewee. I will pass on this feature.

0reactions
savrajcommented, Jan 3, 2017

for future MySQL readers, the way I chose to do this (after ending up here) was this:

    db = MySQLdb.connect(host='', user='', passwd='')
    c = db.cursor()
    c.execute("drop database %s" % db_name)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Staged Database Systems - CMU School of Computer Science
My thesis proposal introduces the Staged Database System design for ... they update the server's statistics, and create/destroy the client's state and ...
Read more >
Domain model and PHP's create/destroy nature - PHP - SitePoint ...
I'm just thinking that because PHP continually needs to work with persistent storage… databases primarily, how far does one go with the “pure”...
Read more >
create-destroy-job — OCI CLI Command Reference 2.22.0 ...
Specifies the source of the execution plan to apply. Currently, only AUTO_APPROVED is allowed, which indicates that the job will be run without...
Read more >
How to Implement Multi-Master Replication in Polyhedra
ments on the underlying database and is not easy to port to another DBMS since it makes use of Polyhedra specific API's. The...
Read more >
Proceedings of the Object-Oriented Database Task Group ...
The workshop attempted to focus on concrete proposals ... PROPOSITION U: Functions, including database procedures and methods, and.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found