q2rad 0.1.200__tar.gz → 0.1.201__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of q2rad might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: q2rad
3
- Version: 0.1.200
3
+ Version: 0.1.201
4
4
  Summary: RAD - database, GUI, reports
5
5
  Author: Andrei Puchko
6
6
  Author-email: andrei.puchko@gmx.de
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "q2rad"
3
- version = "0.1.200"
3
+ version = "0.1.201"
4
4
  description = "RAD - database, GUI, reports"
5
5
  authors = ["Andrei Puchko <andrei.puchko@gmx.de>"]
6
6
  readme = "README.md"
@@ -26,6 +26,16 @@ from datetime import datetime
26
26
  import json
27
27
  import os
28
28
 
29
+ app_tables = [
30
+ "forms",
31
+ "lines",
32
+ "actions",
33
+ "reports",
34
+ "modules",
35
+ "queries",
36
+ "packages",
37
+ ]
38
+
29
39
 
30
40
  class AppManager(Q2Form):
31
41
  def __init__(self, title=""):
@@ -307,7 +317,7 @@ class AppManager(Q2Form):
307
317
  file = self.validate_impexp_file_name(file, filetype)
308
318
  if file:
309
319
  if app_json is None:
310
- app_json = self.get_app_json()
320
+ app_json = q2working(self.get_app_json, "Prepare data...")
311
321
  if app_json:
312
322
  json.dump(app_json, open(file, "w"), indent=1)
313
323
 
@@ -315,6 +325,8 @@ class AppManager(Q2Form):
315
325
  db: Q2Db = q2app.q2_app.db_logic
316
326
  rez = {}
317
327
  for x in db.get_tables():
328
+ if x not in app_tables:
329
+ continue
318
330
  if x.startswith("log_") or x == "sqlite_sequence":
319
331
  continue
320
332
  rez[x] = []
@@ -332,18 +344,23 @@ class AppManager(Q2Form):
332
344
 
333
345
  file = self.validate_impexp_file_name(file, filetype)
334
346
  if file:
335
- db: Q2Db = q2app.q2_app.db_data
336
- rez = {}
337
- for x in db.get_tables():
338
- if x.startswith("log_") or x == "sqlite_sequence":
339
- continue
340
- rez[x] = []
341
- for row in db.table(x).records():
342
- rez[x].append(row)
343
-
347
+ rez = q2working(self.get_data_json, "Prepare data...")
344
348
  if rez:
345
349
  json.dump(rez, open(file, "w"), indent=1)
346
350
 
351
+ def get_data_json(self):
352
+ db: Q2Db = q2app.q2_app.db_data
353
+ rez = {}
354
+ for x in db.get_tables():
355
+ if x in app_tables:
356
+ continue
357
+ if x.startswith("log_") or x == "sqlite_sequence":
358
+ continue
359
+ rez[x] = []
360
+ for row in db.table(x).records():
361
+ rez[x].append(row)
362
+ return rez
363
+
347
364
  def import_q2market(self):
348
365
  self.q2_app.check_app_update(force_update=True)
349
366
 
@@ -373,9 +390,9 @@ class AppManager(Q2Form):
373
390
  continue
374
391
  wait_row = Q2WaitShow(len(data[table]))
375
392
  if table != "packages":
376
- db.cursor(f'delete from `{table}` where name not like "\_%"')
393
+ db.cursor(f'delete from `{table}` where name not like "\\_%"')
377
394
  if db.last_sql_error:
378
- print(db.last_sql_error)
395
+ errors.append(db.last_sql_error)
379
396
  for row in data[table]:
380
397
  wait_row.step()
381
398
  if table == "packages":
@@ -384,6 +401,8 @@ class AppManager(Q2Form):
384
401
  == row["package_name"]
385
402
  ):
386
403
  continue
404
+ if row.get("name", "").startswith("_"):
405
+ continue
387
406
  if not db.insert(table, row):
388
407
  errors.append(db.last_sql_error)
389
408
  errors.append(db.last_record)
@@ -15,7 +15,7 @@
15
15
 
16
16
  from q2gui.q2model import Q2CursorModel
17
17
  from q2rad.q2raddb import Q2Cursor, insert
18
- from q2gui.q2dialogs import q2AskYN
18
+ from q2gui.q2dialogs import q2AskYN, q2mess
19
19
  from q2rad.q2utils import q2cursor, choice_table, choice_column, choice_form, Q2_save_and_run
20
20
  from q2rad.q2raddb import last_error
21
21
 
@@ -99,6 +99,7 @@ class Q2Lines(Q2Form, Q2_save_and_run):
99
99
  self.add_action("Layout|Form", icon="☆", worker=lambda: self.add_layout("/f"))
100
100
  self.add_action("Layout|Horizontally", worker=lambda: self.add_layout("/h"))
101
101
  self.add_action("Layout|Vertically", worker=lambda: self.add_layout("/v"))
102
+ self.add_action("Alter column", icon="🔧", worker=self.alter_column)
102
103
 
103
104
  def create_form(self):
104
105
  self.add_control("id", "", datatype="int", pk="*", ai="*", noform=1, nogrid=1)
@@ -130,7 +131,7 @@ class Q2Lines(Q2Form, Q2_save_and_run):
130
131
  self.add_control("/")
131
132
  if self.add_control("/h"):
132
133
  self.add_control("stretch", _("Stretch factor"), datatype="int")
133
- self.add_control("alignment", _("Alignment"), datatype="int",datalen=3)
134
+ self.add_control("alignment", _("Alignment"), datatype="int", datalen=3)
134
135
  self.add_control("tag", _("Tag"), datatype="char", datalen=100)
135
136
  self.add_control("/")
136
137
  if self.add_control("/h", _("Control type")):
@@ -277,6 +278,13 @@ class Q2Lines(Q2Form, Q2_save_and_run):
277
278
  self.controls.delete("save_and_run_actions_visible")
278
279
  self.system_controls.insert(2, self._save_and_run_control)
279
280
 
281
+ def alter_column(self):
282
+ if self.r.migrate and q2AskYN(f"Alter column {self.r.column}?") == 2:
283
+ record = self.get_current_record()
284
+ record["table"] = self.db.get("forms", f"name = '{self.prev_form.r.name}'", "form_table")
285
+ if not q2app.q2_app.db_data.alter_column(record):
286
+ q2mess(self.db_data.migrate_error_list)
287
+
280
288
  def copy_to(self):
281
289
  rows = self.get_grid_selected_rows()
282
290
  choice = choice_form()
@@ -374,20 +382,21 @@ class Q2Lines(Q2Form, Q2_save_and_run):
374
382
 
375
383
  cols = self.q2_app.db_data.db_schema.get_schema_columns(self.prev_form.r.form_table)
376
384
  for x in cols:
377
- insert(
378
- "lines",
379
- {
380
- "name": self.prev_form.r.name,
381
- "column": x,
382
- "label": x,
383
- "datatype": cols[x]["datatype"],
384
- "datalen": cols[x]["datalen"],
385
- "pk": cols[x]["pk"],
386
- "ai": cols[x]["ai"],
387
- "migrate": "*",
388
- },
389
- self.db,
390
- )
385
+ if self.db.get("lines", f"name = '{self.prev_form.r.name}' and column = '{x}'") == {}:
386
+ insert(
387
+ "lines",
388
+ {
389
+ "name": self.prev_form.r.name,
390
+ "column": x,
391
+ "label": x,
392
+ "datatype": cols[x]["datatype"],
393
+ "datalen": cols[x]["datalen"],
394
+ "pk": cols[x]["pk"],
395
+ "ai": cols[x]["ai"],
396
+ "migrate": "*",
397
+ },
398
+ self.db,
399
+ )
391
400
  self.refresh()
392
401
 
393
402
  def before_crud_save(self):
@@ -421,7 +421,6 @@ class Q2RadApp(Q2App):
421
421
  def _open_database(self, database_name, db_engine_name, host, port, password, user, guest_mode=None):
422
422
  db = None
423
423
  first_pass = 0
424
-
425
424
  while True:
426
425
  try:
427
426
  db = q2working(
@@ -465,7 +464,8 @@ class Q2RadApp(Q2App):
465
464
  ),
466
465
  mess=_("Creating database"),
467
466
  )
468
- except Exception:
467
+ except Exception as error:
468
+ q2mess(f"Error occured while creating the database:<br>{error}")
469
469
  return None
470
470
 
471
471
  def open_databases(self):
@@ -491,7 +491,7 @@ class Q2RadApp(Q2App):
491
491
  self.last_root_password = ""
492
492
  if self.db_data is None or self.db_logic is None:
493
493
  self.selected_application = {}
494
- q2Mess(_("Can not open database"))
494
+ # q2Mess(_("Can not open database"))
495
495
  self.open_application()
496
496
 
497
497
  def create_menu(self):
@@ -799,7 +799,7 @@ class Q2RadApp(Q2App):
799
799
  f" {_source_suffix}{package}{_source_postfix}"
800
800
  )
801
801
  if trm.exit_code != 0:
802
- q2mess(f"Error occured while updateing <b>{package}</b>! See output for details.")
802
+ q2mess(f"Error occured while updating <b>{package}</b>! See output for details.")
803
803
  w.close()
804
804
  q2Mess("Finished!<p>The program will be restarted!")
805
805
  self.restart()
@@ -226,7 +226,8 @@ class Q2Form(_Q2Form):
226
226
  f"""select *
227
227
  from log_{self.model.get_table_name()}
228
228
  {where}
229
- """
229
+ """,
230
+ self.db,
230
231
  )
231
232
  form = Q2Form(f"Changelog ({self.title})")
232
233
  form.add_control("/")
@@ -282,10 +283,10 @@ class Q2Form(_Q2Form):
282
283
 
283
284
 
284
285
  class q2cursor(Q2Cursor):
285
- def __init__(self, sql="", q2_db=None):
286
+ def __init__(self, sql="", q2_db=None, data=[]):
286
287
  if q2_db is None:
287
288
  q2_db = q2app.q2_app.db_data
288
- super().__init__(q2_db, sql)
289
+ super().__init__(q2_db, sql, data=data)
289
290
  if q2_db.last_sql_error:
290
291
  print(q2_db.last_sql_error)
291
292
 
@@ -0,0 +1 @@
1
+ __version__ = "0.1.201"
@@ -1 +0,0 @@
1
- __version__ = "0.1.200"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes